There is probably a simple solution to this but I need to resolve very urgently. Unfortunately I'm not too good with SQL!
I have a T-SQL query for SQL 2008
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
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]
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?