| Author |
Topic  |
|
|
anuraag205
Yak Posting Veteran
India
51 Posts |
Posted - 09/24/2012 : 03:27:07
|
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
1437 Posts |
Posted - 09/24/2012 : 03:39:59
|
Hi anuraag,
USe IN instead of = operator
fk_statusid IN (3,5)
-- Chandu |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1437 Posts |
Posted - 09/24/2012 : 03:40:00
|
Hi anuraag,
USe IN instead of = operator
fk_statusid IN (3,5)
-- Chandu |
 |
|
|
anuraag205
Yak Posting Veteran
India
51 Posts |
Posted - 09/24/2012 : 03:45:57
|
Thanks Bandi...That Worked...
Thanks |
 |
|
|
bandi
Flowing Fount of Yak Knowledge
India
1437 Posts |
Posted - 09/24/2012 : 03:46:34
|
Welcome
-- Chandu |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 09/24/2012 : 13:13:03
|
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/
|
 |
|
| |
Topic  |
|