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-29 : 09:13:50
|
| This is my new query and i need to find 12% of "Sales Value"....how can i achive that ...please guide me.....now i get a list of data...but i just need end result of :12%: of :Sales Value:Please help???::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::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/June/2011'Set @EndDate='01/Jul/2012'Set @SiteID = 'UW'SELECT tblInvoice.BookingDate, tblInvoice.InvoiceNumber, tblInvoice.CollectionLocation, tblInvoice.ReturnLocation, (case tblInvoice.fk_StatusID when 1 then 'Abandoned' when 2 then 'Quote' when 3 then 'Invoice' when 4 then 'Action Needed' when 5 then 'Cancelled' end)AS [status] , ( case when isnull(tblInvoice.NegotiatedSellPrice,0)=0 then tblInvoice.SuggestedSellPrice else tblInvoice.NegotiatedSellPrice end )as [Sales Value] , (case when Isnull(tblInvoice.IsAgent,0)=1 then 'Agent' when isnull(tblInvoice.fk_IntroducerID,0)<>0 then 'Introducer' else 'Direct' end) as [Intro], tblCountry.CountryName As Origin,tblInvoice.IntroducerNameFROM 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.DriverName <> 'MR T TEST')--and tblInvoice.fk_introducerid=798--For PPC Booking--and tblInvoice.fk_introducerid=801--For Shareasale Boikoin--and tblInvoice.fk_introducerid=816--For TD Booking--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--select fk_statusid,invoicenumber,drivername from tblinvoice where fk_statusid<>2 and fk_introducerid=798 and bookingdate between @StartDate and @EndDate --select fk_statusid,invoicenumber,drivername from tblinvoice where fk_statusid<>2 and fk_introducerid=801 and bookingdate between @StartDate and @EndDate--select fk_statusid,invoicenumber,drivername from tblinvoice where fk_statusid<>2 and fk_introducerid=802 and bookingdate between @StartDate and @EndDate--select fk_statusid,invoicenumber,drivername from tblinvoice where fk_statusid<>2 and fk_introducerid=803 and bookingdate between @StartDate and @EndDate--select fk_statusid,invoicenumber,drivername from tblinvoice where fk_statusid<>2 and fk_introducerid=807 and bookingdate between @StartDate and @EndDateThanks |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2012-08-29 : 09:36:32
|
Did you try this?[Sales Value]*0.12 CODO ERGO SUM |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-29 : 12:49:14
|
| salesvalue being derived column you need to add * 0.12 towards end of case ...when------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|