hi Naomi
i try row number but still is showing same result hear is my string with ROW_NUMBER()
SELECT MAX(Row), CustId, OrderDesc, Price, OrderByDeptId FROM (SELECT
ROW_NUMBER() OVER(ORDER BY (DeliveryNoteDt) DESC) AS Row,
s2.DeliveryNoteDt,
s1.OrderDesc,
s1.CustId,
s1.Price,
s1.OrderByDeptId,
ISNULL(s1.ExpectedWeight,0) ExpectedWeight
FROM dbo.tblDeliveryNote AS s2
INNER JOIN dbo.tblJobCard_Mst AS s1
ON s2.JobcardId = s1.JobCardId WHERE (YEAR(s2.DeliveryNoteDt) = '2013')) A
GROUP BY CustId, OrderDesc, Price, OrderByDeptId
ORDER BY CustId, OrderDesc
Result
ROW | CUSTID | PRODID | RATE | DEPTID |
430 | CUST-00038 | PROD-01395 | 550 | 5 |
3777 | CUST-00038 | PROD-01401 | 250 | 5 |
3776 | CUST-00038 | PROD-01403 | 250 | 5 |
1236 | CUST-00038 | PROD-02237 | 11000 | 5 |
1237 | CUST-00038 | PROD-02238 | 11000 | 5 |
1238 | CUST-00038 | PROD-03762 | 160 | 5 |
596 | CUST-00040 | 416 | 11 | 2 |
3515 | CUST-00040 | 727 | 38.75 | 2 |
298 | CUST-00040 | 971 | 41 | 2 |
2368 | CUST-00040 | 971 | 41.35 | 2 |
No comments:
Post a Comment