GROUPING 功能怎么使啊?(100)

  • 主题发起人 主题发起人 qumingfei
  • 开始时间 开始时间
Q

qumingfei

Unregistered / Unconfirmed
GUEST, unregistred user!
SELECT Q_REALDATE= case when (GROUPING(Q_PLACE) = 0) THEN q_realdate when (GROUPING(Q_REALDATE) = 1) THEN '2222-2-2' ELSE ISNULL(Q_REALDATE, '2009-2-2') end , Q_SDDD= case when (GROUPING(Q_PLACE) = 0) THEN Q_SDDD when (GROUPING(Q_SDDD) = 1) THEN ' ' ELSE ISNULL(Q_SDDD, ' ') end , Q_PLACE=CASE WHEN (GROUPING(Q_PLACE)=0) THEN Q_PLACE WHEN (GROUPING(Q_PLACE)=1) AND (GROUPING(Q_SDDD) = 0) THEN '小计' else isnull(Q_PLACE,'UNKWOWN') end ,sum(SUMQTY),SUM(SUMBOX) as SUMT,Q_EMPNAME,Q_AUTONO FROM QUMF WHERE q_realdate is not null GROUP BY Q_REALDATE,Q_SDDD,Q_PLACE,Q_EMPNAME,Q_AUTONO WITH ROLLUP2008-09-15 00:00:00.000 绍兴 海神 6324.000 18.000 刘长燕 8090166 2008-09-15 00:00:00.000 绍兴 海神 6324.000 18.000 刘长燕 NULL2008-09-15 00:00:00.000 绍兴 海神 6324.000 18.000 NULL NULL2008-09-15 00:00:00.000 绍兴 小计 6324.000 18.000 NULL NULL
 
这不是我期望的结果,我希望是2008-09-15 00:00:00.000 绍兴 海神 6324.000 18.000 刘长燕 8090166 2008-09-15 00:00:00.000 绍兴 小计 6324.000 18.000 NULL NULL
 
再加个条件判断 ,where Q_PLACE<>'小计' and Q_AUTONO <>null 看看
 
后退
顶部