Hi I have a Sql Qeries which Queries Two Tables. and returns the DISTINCT Recrds.
I want to write a Function so I can get the Total of Products in my result (because I want to keep Distinct records I dont want products to show in Query.
I am trying to write a function something like this...
ALTER Function clineTotal
@SKU varchar (100)
Declare @output varchar(1000)
if Exists(Select ItemSku From Intranet.dbo.po_header_lines where ORDERID=@ORDR AND ItemSku=@SKU)
-- ITEM is in that Table Calclute the COST OF IT, Add up to @output Variable
-- ITEM is not in Table Grab the Product PO PRICE and Add up to @output variable
RETURN -- THE Total of output variable
So i am passing the Order number and the Item SKU and return the Total Cost.
is it possible to do?