The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!
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
How can I merge the two select statements into one so I see the Budget / Billing / Booking columns in the same result?Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Join the community of 500,000 technology professionals and ask your questions.