Wednesday, 21 August 2013

Using Aggregate function in where clause and a different column criteria

Using Aggregate function in where clause and a different column criteria

select PO_Order_Qty, Avg([PO_Order_Qty])as totalAverage
FROM [FirstStrike_Retail].[custom].[Whse_Pricing_QR]
where item_code ='111' and PO_order_qty <(Avg([PO_Order_Qty])*2)
group by PO_Order_Qty
I am using the above sql in MS Sql to get the average on a particular item
codes order qty. I am expecting only one return value.
And i need to eliminate if any of the qty is above twice the average.
Thanks Xplr

No comments:

Post a Comment