I have a Budget table with field names "SSBJAN", "SSBFEB", "SSMAR", etc for the year
My select query which works ok below, I currently change manually "SSBMAY" each month:
SELECT SADIVO AS Division, SAWHSL AS Location, SSBMAY as BudgetSales,
FROM BBSCDTA.SA04WH
I wish this to pickup from Month(Today())
with the current Month 'mmm' so I can append it to SSB so it auto selects current month from table.
Below I have created this in QlikView coding but am not able to get this working in Report Designer SQL.
My code for Qlikview
Let Today='03/05/2012';
let CalBud1=Upper(Month(Today()));
let SSB=Upper('SSB');
let vCalBud=SSB&CalBud1;
This returns "SSBMAY" and next month it returns "SSBJUN"
Assuming that you want the query for T-SQL (Microsoft's dialect of SQL)
SELECT
SADIVO AS Division,
SAWHSL AS Location,
CASE MONTH(GETDATE())
WHEN 1 THEN SSBJAN
WHEN 2 THEN SSBFEB
WHEN 3 THEN SSBMAR
WHEN 4 THEN SSBAPR
WHEN 5 THEN SSBMAY
WHEN 6 THEN SSBJUN
WHEN 7 THEN SSBJUL
WHEN 8 THEN SSBAUG
WHEN 9 THEN SSBSEP
WHEN 10 THEN SSBOCT
WHEN 11 THEN SSBNOV
WHEN 12 THEN SSBDEC
END as BudgetSales
FROM BBSCDTA.SA04WH