SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 combine 2 queries
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

devid3an
Starting Member

2 Posts

Posted - 11/01/2013 :  06:57:32  Show Profile  Reply with Quote
hey been trying a few different things but not working any help please would be awesome. its 2 separate queries with the same select commands would like this to be in one report, thank you so much

SELECT
POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,count(POLINE.ProductCode)
,POHEAD.PostStatus
FROM POHEAD
JOIN POLINE ON POHEAD.DocumentID=POLINE.DocumentID
WHERE POHEAD.Z_ArrivalDate <> '' and POHEAD.Z_CountedDate <> '' and POHEAD.Z_CountedDate >= :fromdate and POHEAD.Z_CountedDate <= :todate
GROUP BY POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,POHEAD.PostStatus
ORDER BY POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime


SELECT
POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,count(POLINE.ProductCode)
,POHEAD.PostStatus
FROM POHEAD
JOIN POLINE ON POHEAD.DocumentID=POLINE.DocumentID


WHERE POHEAD.Z_ArrivalDate <> '' and POHEAD.Z_CountedDate = '' and POHEAD.PostStatus = 'U' and POHEAD.QuantityReceipted = 0
GROUP BY POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,POHEAD.PostStatus
ORDER BY POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime

madhivanan
Premature Yak Congratulator

India
22772 Posts

Posted - 11/01/2013 :  07:32:50  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
Qyuery1
union all
Query2

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 11/01/2013 :  13:20:03  Show Profile  Reply with Quote
you want to get count values in same row or appear as two rows for each combination?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000