我们有一个很大的订单表,这些订单在处理时按PurchaseOrderNumber、AccountNumber和ProductType分组。客户端请求我们根据InsertionTimestamp处理这些订单。
下面是我们使用的查询,它工作正常,但需要根据客户端的请求进行更改。
Select Purchase_Order_Number, Account_Number, Max(LineNumber) LineNumber, Product_Type
From dbo.PDF_Orders_Validation
Where BotReady = 'Y'
Group By Purchase_Order_Number, Account_Number, Product_Type
我试过但不管用...
Select Purchase_Order_Number, Account_Number, Max(LineNumber) LineNumber, Product_Type
From dbo.PDF_Orders_Validation
Where BotReady = ''
Group By Purchase_Order_Number, Account_Number, Product_Type
Order By InsertionTimestamp
我也试过这个...
Select Purchase_Order_Number, Account_Number, Max(LineNumber) LineNumber, Product_Type
From dbo.PDF_Orders_Validation
Where BotReady = ''
Group By Purchase_Order_Number, Account_Number, Product_Type, InsertionTimestamp
Order By InsertionTimestamp
...该方法有效,但创建了太多行,可能会导致订单重复。
我需要的是保留原始查询,但只需按InsertionTimestamp的升序对行重新排序。
对此的任何帮助将不胜感激。
1条答案
按热度按时间zsbz8rwp1#
你试过这个吗?
注意--不确定您的处理管道,因此可能需要MIN()而不是MAX()