This is my criteria below for my parameters and sql code given pleas asisst
Criteria will be
- Product type : All or product types (Drop down)
- ISBN field : if empty then ignore
- Date Start, Date End = default to today
use BusinessEvents
use BusinessEvents
SELECT oh.[OrderId]
,oh.[CustomerId]
, c.FirstName +' '+ c.LastNameas CustomerName
,oh.[OrderDate]
,P.ProdId
,P.Barcode
, rtrim(p.ProdName+' '+isnull(p.subtitle,''))
, op.[Type] as PaymentMethod
, oce.Quantity as ItemQty
, oce.Price as ItemPrice
, oh.Statusas OrderStatus
,oce.Statusas ItemStatus
FROM [dbo].[OrderHeader] oh(NOLOCK)
leftouterjoin dbo.Customer c(NOLOCK)on oh.CustomerId = c.CustomerId
leftouterjoin [dbo].[OrderPayment] op(NOLOCK)on oh.OrderId = op.orderId
leftouterjoin [dbo].[OrderConsignment] oc(NOLOCK)on oh.OrderId = oc.orderId
leftouterjoin [dbo].[OrderConsignmentEntry] oce(NOLOCK)on oc.ConsignmentCode= oce.ConsignmentCode
innerjoin product..Product p(nolock)on oce.ProductId = p.prodId
innerjoin product..producttype pt(NOLOCK)on p.prodTypeId = pt.prodTypeId
Where
(pt.ProductType={report field : Product Type}or {report field}='All')
and
p.Barcodelike'%'+{Report field : Barcode}
and
oh.[OrderDate]>={report field:Date start}
and
oh.[OrderDate]<={report field:Date End}
orderby oh.orderid