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
 Query doubt
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anuraag205
Yak Posting Veteran

India
58 Posts

Posted - 09/24/2012 :  03:27:07  Show Profile  Reply with Quote
On the 13 th line of this query i need to get results of fk_statusid=3 and 5. Here below am able to get only 3.... how can i get 5 also???

=========================================================================================================================================== Declare @GroupCode as varchar(10)
Declare @StartDate as varchar(12)
Declare @EndDate as varchar(12)
Declare @SiteID as varchar(3)

Set NOCOUNT OFF

Set @StartDate='01/sep/2012'
Set @EndDate='01/oct/2012'
Set @SiteID = 'UW'

Select tblCountry.CountryName, COUNT(tblInvoice.InvoiceNumber) AS [Total Bookings]
FROM tblInvoice INNER JOIN
tblClient ON tblInvoice.fk_ClientID = tblClient.pk_ClientID INNER JOIN
tblCountry ON tblClient.fk_CountryID = tblCountry.pk_CountryID
where BookingDate between @StartDate and @EndDate and siteid=@SiteID and fk_statusid=3
--and tblInvoice.fk_introducerid=798--For PPC Booking
--and tblInvoice.fk_introducerid=801--For Shareasale Boikoin
--and tblInvoice.fk_introducerid=802--For Yahoo SM
--and tblInvoice.fk_introducerid=803--For MSN AD Center
--and tblInvoice.fk_introducerid=807--For PSMAmericaCarRental
---and tblInvoice.fk_statusid=3
---and tblInvoice.dbo.tblVehicleCategory.pk_CategoryID=193
--and tblInvoice.invoicenumber in ('UW005234','UW005244','UW005273')
--order by tblInvoice.invoicenumber
GROUP BY tblCountry.CountryName
ORDER BY COUNT(tblInvoice.InvoiceNumber)desc
===========================================================================================================================================

Thanks

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 09/24/2012 :  03:39:59  Show Profile  Reply with Quote
Hi anuraag,

USe IN instead of = operator

fk_statusid IN (3,5)

--
Chandu
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 09/24/2012 :  03:40:00  Show Profile  Reply with Quote
Hi anuraag,

USe IN instead of = operator

fk_statusid IN (3,5)

--
Chandu
Go to Top of Page

anuraag205
Yak Posting Veteran

India
58 Posts

Posted - 09/24/2012 :  03:45:57  Show Profile  Reply with Quote
Thanks Bandi...That Worked...

Thanks
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2223 Posts

Posted - 09/24/2012 :  03:46:34  Show Profile  Reply with Quote
Welcome

--
Chandu
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 09/24/2012 :  13:13:03  Show Profile  Reply with Quote
if you want it make it future maintainable and scalable better approach would be to use a table to hold id valuess along with descriptions and then add a join to it in above query. by doing this you dont have worry about hardcoding id values and keeping on changing the query each time an id gets added,modified or removed. whatever changes happens, you just need to do single DML (Insert,update,delete) operation on your table rather than on the query.
If its one time activity, then above approach is good enough

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

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.08 seconds. Powered By: Snitz Forums 2000