阿靠北啊 2022-09-21 20:02

想在tableau中,将下面的SQL条件转换成计算字段的写法。 请看看如何写?

业务需求是:当月同ueser、同lead_type下 且 current_state != 6 的数据 ,要加上当月同ueser、同lead_type下,在后续月份出现过,并按lead_type,user_id去重的数据

  1. 1. countlead_type=0,且 leads.score >=110 ,且 leads. build_time 在查询月份内时,current_status!=6
  2. SELECT * FROM leads WHERE lead_type = 0 AND score >= 110 AND current_state != 6 AND build_time >= '2022-08-01 00:00:00' AND build_time < '2022-09-01 00:00:00'
  3. UNION ALL
  4. 2. count(第1条中,用户同lead_type,在后续月份有 大于等于1条线索,计数为1
  5. SELECT * FROM leads WHERE lead_type = 0 AND build_time >= '2022-09-01 00:00:00' AND current_state != 6 AND user_id IN(
  6. SELECT user_id FROM leads WHERE lead_type = 0 AND score >= 110 AND current_state = 6 AND build_time >= '2022-08-01 00:00:00' AND build_time < '2022-09-01 00:00:00'
  7. )