Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 adding a parameter to items in where command

Author  Topic 

devid3an
Starting Member

2 Posts

Posted - 2013-11-06 : 03:39:53
hey I have 3 specific where searches in where command I want to add a defined text to each specific where query if that makes sense. highlighted in red, how do I do this? going to add status after and then do pivot table afterwards.

thanks

SELECT

POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate
,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,POHEAD.PostStatus
,POHEAD.daterequired
,count(POLINE.ProductCode)
,count(POHEAD.quantityOrdered)


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

status = counted

or POHEAD.Z_ArrivalDate <> '' and POHEAD.Z_CountedDate = '' and POHEAD.PostStatus = 'U' and POHEAD.QuantityReceipted = 0

status = arrived



OR POHEAD.Z_ArrivalDate = '' AND POHEAD.daterequired BETWEEN :todate -10 AND (:TODATE))

status = arrived

GROUP BY


POHEAD.DocumentNo
,POHEAD.CreditorCode
,POHEAD.InternalReference
,POHEAD.QuantityOrdered
,POHEAD.Z_ArrivalDate

,POHEAD.Z_ArrivalTime
,POHEAD.Z_CountedDate
,POHEAD.Z_CountedTime
,POHEAD.PostStatus
,POHEAD.daterequired




order by 7,8,5,6,10

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-11-06 : 04:08:36
sorry didnt get your actual requirement.
Can you show some sample data and then explain what you want as output.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -