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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 adding a parameter to items in where command
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

devid3an
Starting Member

2 Posts

Posted - 11/06/2013 :  03:39:53  Show Profile  Reply with Quote
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

India
52326 Posts

Posted - 11/06/2013 :  04:08:36  Show Profile  Reply with Quote
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
  Previous Topic Topic Next 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.09 seconds. Powered By: Snitz Forums 2000