Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select multiple columns Help 1

Status
Not open for further replies.

michaela18

Technical User
Sep 9, 2009
37
US

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
 
When I do that:

select vendorcode, orderdate, deliverdate
group by vendorcode, orderdate, deliverdate

it would give me those columns but not wit the dates i specified
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top