ALTER proc [dbo].[h_reporttotalqtyindatereange]
@vid1 varchar(8000),
@date1 varchar(20),
@date2 varchar(20),
@category varchar(8000)
as
declare @vid varchar(8000)
select @vid=@vid1
SELECT DISTINCT
dbo.getvendornamewithoutrules(h_items.item_id) AS vendor, dbo.lowestcostinlistofvendors(h_items.item_id, @vid) AS lowprice,
h_po_detail.po_detail_item, SUM(CAST(h_po_detail.po_detail_quantity AS numeric) * CAST(h_items_cost.items_cost_price AS money)) AS amount,
SUM(CAST(h_po_detail.po_detail_quantity AS numeric)) AS Qty, h_items.item_name, h_items.item_category, h_categories.categories_name
FROM h_po_detail INNER JOIN
h_items ON h_po_detail.po_detail_item = h_items.item_id INNER JOIN
h_categories ON h_items.item_category = h_categories.categories_id INNER JOIN
h_vendors ON h_po_detail.po_detail_vendor = h_vendors.vendor_id LEFT OUTER JOIN
h_items_cost ON h_po_detail.po_detail_uom = h_items_cost.items_cost_id
WHERE (h_items.item_category IN (@category)) AND (h_po_detail.po_detail_create_date BETWEEN @date1 AND @date2)
GROUP BY dbo.getvendornamewithoutrules(h_items.item_id), dbo.lowestcost(h_items.item_id), h_po_detail.po_detail_item, h_items.item_name,
h_items.item_category, h_categories.categories_name, h_items.item_id
ORDER BY Qty DESC
|