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.
| Author |
Topic |
|
anuraag205
Yak Posting Veteran
58 Posts |
Posted - 2012-08-24 : 05:45:56
|
| I have the below type of query, but i have to remove "--"every time for knowing the details...Is there any way for me to find the data using single query??I aslo wanted to add the sum of all bookings amount and pay % wise comission to those "ppcbookings, yahoosm, msnadcentre...and others...please help...here is the sample query."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/APR/2011'Set @EndDate='30/APR/2011'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_CountryIDwhere BookingDate between @StartDate and @EndDate and siteid=@SiteID and fk_statusid<>2 --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.invoicenumberGROUP BY tblCountry.CountryNameORDER BY COUNT(tblInvoice.InvoiceNumber)DESCThanks |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-08-24 : 06:00:13
|
| Not sure what you are afterThe criteria that is just fk_introducerid is easy - for the others - are they uncommented as well as the fk_introducerid ?MaybeSelect tblCountry.CountryName, tblInvoice.fk_introducerid, COUNT(tblInvoice.InvoiceNumber) AS [Total Bookings]FROM tblInvoice INNER JOINtblClient ON tblInvoice.fk_ClientID = tblClient.pk_ClientID INNER JOINtblCountry ON tblClient.fk_CountryID = tblCountry.pk_CountryIDwhere BookingDate between @StartDate and @EndDate and siteid=@SiteID and fk_statusid<>2 and tblInvoice.fk_introducerid in (798,801,802,803,807)and tblInvoice.fk_statusid=3 and tblInvoice.dbo.tblVehicleCategory.pk_CategoryID=193and tblInvoice.invoicenumber in ('UW005234','UW005244','UW005273')GROUP BY tblCountry.CountryName, tblInvoice.fk_introducerid==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
anuraag205
Yak Posting Veteran
58 Posts |
Posted - 2012-08-24 : 07:52:00
|
| Thanks for your reply. i solved it for today...really can't put up in right words...thanks again,.Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|