michaela18
Technical User
I have the following query which just pulls in the VendorCode. But is it possible to also display the orderdate and Deliverdate. As you can see I have 2 different dates. Please help. Thanks
Code:
select VendorCode,
count(case when Orderdate = '20100203'
and Rush = 'N'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
then 1 end) as [BMNS_Order],
count(case when Deliverdate = '20100203'
and Rush = 'N'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
then 1 end) as [BMNS_Deliver],
count(case when Orderdate = '20100203'
and Rush = 'N'
and package IN ('ABVX114', 'ABVX116')
then 1 end) as [ASDE_Order],
count(case when Deliverdate = '20100203'
and Rush = 'N'
and package IN ('ABVX114', 'ABVX116')
then 1 end) as [ASDE_Deliver],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'P'
then 1 end) as [QAWE_Pri_Order],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'S'
and TranCode = 'E'
then 1 end) as [QAWE_Sec_Order],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'P'
then 1 end) as [QAWE_New_Order],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'P'
then 1 end) as [QAWE_Pri_Deliver],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'S'
and TranCode = 'E'
then 1 end) as [QAWE_Sec_Deliver],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX107', 'ABVX108', 'ABVX110')
and DeliveryCode = 'P'
then 1 end) as [QAWE_New_Deliver],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'P'
then 1 end) as [WEQS_Pri_Order],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'S'
and TranCode = 'E'
then 1 end) as [WEQS_Sec_Order],
count(case when Orderdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'P'
then 1 end) as [WEQS_New_Order],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'P'
then 1 end) as [WEQS_Pri_Deliver],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'S'
and TranCode = 'E'
then 1 end) as [WEQS_Sec_Deliver],
count(case when Deliverdate = '20100203'
and Rush = 'Y'
and package IN ('ABVX114', 'ABVX116')
and DeliveryCode = 'P'
then 1 end) as [WEQS_New_Deliver]
From ABVXrecord
where Pending in ('In Transit', 'Fulfilled Order')
and Budget <> ''
and Vendorcode in ('HJ', 'LK')
group by VendorCode