日期:2014-05-17 浏览次数:20464 次
select 序号=identity(int,1,1),ddate,cinvcode,ph,hw,sum(qty1) as qty1
into #tmp
from xianCun
where cinvcode IS NOT NULL AND hw IS NOT NULL
group by ddate,cinvcode,ph,hw
order by ddate,cinvcode,ph,hw
select * from #tmp
SELECT 序号= (SELECT COUNT(DISTINCT BINARY_CHECKSUM(ddate,cinvcode,ph,hw))
FROM xianCun
WHERE cinvcode IS NOT NULL AND hw IS NOT NULL
AND (ddate<a.ddate OR (ddate=a.ddate AND (cinvcode<a.cinvcode OR (cinvcode=a.cinvcode AND (ph<a.ph OR (ph=a.ph AND hw<a.hw)))))))+1,
ddate ,
cinvcode ,
ph ,
hw ,
SUM(qty1) AS qty1
FROM xianCun AS a
WHERE cinvcode IS NOT NULL
AND hw IS NOT NULL
GROUP BY ddate ,
cinvcode ,
ph ,
hw