How can I merge the two select statements into one so I see the Budget / Billing / Booking columns in the same result?
DECLARE @thismonth varchar(7) SET @thismonth = CONVERT(varchar(4),GETDATE(),120) + '-' + CONVERT(varchar(2),GETDATE(),101) SELECT [Target] AS [Budget GP] FROM dbo.tblTarget WHERE [SalesChannel] = 'HR' AND [Period] = @thismonth SELECT SUM(ISNULL(CASE WHEN [Trx Type]='credit' THEN (GP * -1) WHEN [Trx Type]='invoice' THEN (GP) END , 0)) AS [Billing] , SUM(ISNULL(CASE WHEN [Trx Type]='booking' THEN GP END , 0)) AS [Booking] FROM dbo.tblTransactions WHERE [Sales Channel] = 'HR' AND [Doc Date YYYY-MM] = @thismonth
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.