我正在写一个查询来获取email1Opened和email1Sent,即yes / no,对于一行中的email_type 1。不在多行上。所以,请你帮我一行打印。
select user_id,
business_id,
email_status,
id, email_type,
case when email_status='open' and email_type = 1 then 'YES' else 'NO' end email1Opened,
case when email_status='Sent' and email_type = 1 then 'YES' else 'NO' end email1Sent
from email_track where business_id = 10;
答案 0 :(得分:0)
如果您只想获得email_type 1,则应在查询中使用其他位置:
select user_id,
business_id,
email_status,
id, email_type,
case when email_status='open' then 'YES' else 'NO' end as email1Opened,
case when email_status='Sent' then 'YES' else 'NO' end as email1Sent
from email_track where business_id = 10 and email_type = 1;