Sql 顺便说一句,lostfields公司并没有暗示这一点。它还没有真正足够解决妨碍此查询的固有基础结构问题performance@CaiusJard我发布了答案之后,似乎有人已经给出了这样的答案 select a.volumeOfUser_Show_Psg,
Sql 顺便说一句,lostfields公司并没有暗示这一点。它还没有真正足够解决妨碍此查询的固有基础结构问题performance@CaiusJard我发布了答案之后,似乎有人已经给出了这样的答案 select a.volumeOfUser_Show_Psg, ,sql,sql-server,performance,Sql,Sql Server,Performance,顺便说一句,lostfields公司并没有暗示这一点。它还没有真正足够解决妨碍此查询的固有基础结构问题performance@CaiusJard我发布了答案之后,似乎有人已经给出了这样的答案 select a.volumeOfUser_Show_Psg, b.volumeOfUser_Continue_Psg, (a.volumeOfUser_Show_Psg - b.volumeOfUser_Continue_Psg) as totalNumberCancleProgressSaver fro
顺便说一句,lostfields公司并没有暗示这一点。它还没有真正足够解决妨碍此查询的固有基础结构问题performance@CaiusJard我发布了答案之后,似乎有人已经给出了这样的答案
select a.volumeOfUser_Show_Psg, b.volumeOfUser_Continue_Psg, (a.volumeOfUser_Show_Psg - b.volumeOfUser_Continue_Psg) as totalNumberCancleProgressSaver
from
(select Count(R_CRE_ID) as volumeOfUser_Show_Psg from CADT where CUR_REC like 'Show_Progress_Saver%'
and CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate) a,
(select Count(R_CRE_ID) as volumeOfUser_Continue_Psg from CADT where CUR_REC like 'Continue_Progress_Saver%'
and CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate) b;
SELECT
count(case when cur_rec like 's%' then 1 end) as count_show,
count(case when cur_rec like 'c%' then 1 end) as count_cont
FROM
table
WHERE
computed_column_date BETWEEN @fromdate and @todate ANd
(Cur_rec like 'continue_progress_saver%' or cur_rec like 'show_progress_saver%')
SELECT
count(case when computed_column_left20currec like 's%' then 1 end) as count_show,
count(case when computed_column_left20currec like 'c%' then 1 end) as count_cont
FROM
table
WHERE
computed_column_date BETWEEN @fromdate and @todate AND
computed_column_left20currec in ('show_progress_saver','continue_progress_s')
WITH Data (volumeOfUser_Show_Psg, volumeOfUser_Continue_Psg)
AS
(
SELECT Count(1) AS volumeOfUser_Show_Psg, 0 AS volumeOfUser_Continue_Psg
FROM CADT
WHERE CUR_REC LIKE 'Show_Progress_Saver%' AND CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate
UNION
SELECT Count(1) AS volumeOfUser_Show_Psg, 0 AS volumeOfUser_Continue_Psg
FROM CADT
WHERE CUR_REC LIKE 'Continue_Progress_Saver%' AND CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate
)
SELECT SUM(volumeOfUser_Show_Psg), SUM(volumeOfUser_Continue_Psg), (SUM(volumeOfUser_Show_Psg) - SUM(volumeOfUser_Continue_Psg)) as totalNumberCancleProgressSaver
FROM Data
WITH Data (volumeOfUser_Show_Psg, volumeOfUser_Continue_Psg)
AS
(
SELECT SUM(CASE WHEN CUR_REC LIKE 'Show_Progress_Saver%' THEN 1 ELSE 0 END) AS volumeOfUser_Show_Psg, SUM(CASE WHEN CUR_REC LIKE 'Continue_Progress_Saver%' THEN 1 ELSE 0 END) AS volumeOfUser_Continue_Psg
FROM CADT
WHERE CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate
)
SELECT volumeOfUser_Show_Psg, volumeOfUser_Continue_Psg, (volumeOfUser_Show_Psg - volumeOfUser_Continue_Psg) as totalNumberCancleProgressSaver
FROM Data
SELECT volumeofuser_show_psg, volumeofuser_continue_psg,
( volumeofuser_show_psg - volumeofuser_continue_psg ) AS
totalNumberCancleProgressSaver
(
SELECT
COUNT(CASE WHEN cur_rec LIKE 'Show_Progress_Saver%' then 1 ELSE NULL END) as "volumeofuser_show_psg",
COUNT(CASE WHEN cur_rec LIKE 'Continue_Progress_Saver%' then 1 ELSE NULL END) as "volumeofuser_continue_psg"
FROM cadt
WHERE Cast(r_cre_time AS DATE) >= @fromDate
AND Cast(r_cre_time AS DATE) <= @toDate)
) T;
select a.volumeOfUser_Show_Psg,
a.volumeOfUser_Continue_Psg,
(a.volumeOfUser_Show_Psg - a.volumeOfUser_Continue_Psg) as totalNumberCancleProgressSaver
from(
select sum(case when cur_rec like 'Show%' then 1 else 0 end) as volumeOfUser_Show_Psg,
sum(case when cur_rec like 'Cont%' then 1 else 0 end) as count_cont as volumeOfUser_Continue_Psg
from CADT
where (CUR_REC like 'Show_Progress_Saver%' or CUR_REC like 'Continue_Progress_Saver%')
and CAST(R_CRE_TIME AS DATE) >= @fromDate and CAST(R_CRE_TIME AS DATE) <= @toDate)
) a;