我试图运行 SQL 查询以在 1 行而不是不同的行上显示日期,我还需要确定显示的每个日期之间的天数。
请在当前查询下方找到。
SELECT "Pat_Name",
CASE WHEN "vw_Schedule"."Activity" = '123'
THEN "vw_Schedule"."App_DtTm"
ELSE NULL
END as Consult,
CASE WHEN "vw_Schedule"."Activity" = '456'
THEN "vw_Schedule"."App_DtTm"
ELSE NULL
END as SIM,
CASE WHEN "vw_Schedule"."Activity" = '789'
THEN "vw_Schedule"."App_DtTm"
ELSE NULL
END as PLANNING,
CASE WHEN "vw_Schedule"."SysDefStatus" = 'SC'
THEN "vw_Schedule"."App_DtTm"
ELSE NULL
END as TreatmentStart,
CASE WHEN "vw_Schedule"."SysDefStatus" = 'FC'
THEN "vw_Schedule"."App_DtTm"
ELSE NULL
END as TreatmentFinished
FROM "vw_Schedule"
WHERE "vw_Schedule"."Activity"='123'
or "vw_Schedule"."Activity"='456'
or "vw_Schedule"."Activity"='789'
or "vw_Schedule"."SysDefStatus"='SC'
or "vw_Schedule"."SysDefStatus"='FC'
我希望输出类似于下面
Pat_Name | Consult | Days | SIM | Days | PLANNING | Days | TreatmentStart | Days | TreatmentFinish
Test Pat | 1/9/2013 | 4 | 5/9/2013 | 10 | 15/9/2013 | 3 | 18/9/2013 | 7 | 25/9/2013
谢谢你的帮助。