日期:2014-05-17 浏览次数:20475 次
1. SELECT ROW_NUMBER() over(order by PRODUCTCODE) as ID,BorrowID,sum(quantity)as quantity,CUSTOMERCODE, CUSTOMERNAME, PRODUCTCODE, PRODUCTNAME, BARQUANTITY,PICKDATE
FROM V_INTERFACE WHERE PickDate='2013-01-04' and BorrowID in ('000667972')
ORDER BY PRODUCTCODE ASC
2. select PRODUCTCODE,productname, sum(quantity)as quantity from V_INTERFACE WHERE PickDate='2013-01-04' and BorrowID in ('000667972')
group by PRODUCTCODE,productname
order by quantity desc
SELECT ROW_NUMBER() OVER ( ORDER BY PRODUCTCODE ) AS ID ,
BorrowID ,
b.quantity ,
CUSTOMERCODE ,
CUSTOMERNAME ,
a.PRODUCTCODE ,
a.PRODUCTNAME ,
BARQUANTITY ,
PICKDATE
FROM V_INTERFACE a ,
( SELECT PRODUCTCODE ,
productname ,
SUM(quantity) AS quantity
FROM V_INTERFACE
WHERE PickDate = '2013-01-04'
AND BorrowID IN ( '000667972' )
GROUP BY PRODUCTCODE ,
productname
) b
WHERE a.PRODUCTCODE = b.PRODUCTCODE
AND a.productname = b.productname
AND a.PickDate = '2013-01-04'
AND a.BorrowID IN ( '000667972' )
ORDER BY b.quantity ,
a.PRODUCTCODE
with T
AS(
SELECT
ROW_NUMBER() over(order by PRODUCTCODE) as ID,
BorrowID,
sum(quantity)as quantity,
CUSTOMERCODE,
CUSTOMERNAME,
PRODUCTCODE,
PRODUCTNAME,
BARQUANTITY,
PICKDATE
FROM
V_INTERFACE
WHERE
P