sql统计(多个统计结果)

select count(case when (assessmarks=3 and AssessDate>DateAdd("m", -2, getdate())) then assessmarks end ) as towMonth,
                 count(case when (assessmarks=3 and AssessDate>DateAdd("m", -6, getdate())) then assessmarks end ) as halfYear,
                 count(case when (assessmarks=3 and AssessDate>DateAdd("m", -12, getdate())) then assessmarks end ) as oneYear,
                 count(case when (assessmarks=3 and AssessDate< getdate()) then assessmarks end ) as AllAssess,
                 3 as marks
                 from ProductAssessInfo where userid=345

你可能感兴趣的:(sql)