Hi,
At the moment i have 13 seperate statements selecting a count of records depending on the criteria dates. A few are shown below:-
What i'd like to do is combine these statements into one which can be run, and name each result with an alias, such as period1, period2, period3...
I have tried to code it but am unsure:-
Many thanks,
Alex
At the moment i have 13 seperate statements selecting a count of records depending on the criteria dates. A few are shown below:-
Code:
SELECT count(impactID) as period1 FROM tblBaseData WHERE iyear = 2005 AND iperiod = 9 AND impactId = 1
SELECT count(impactID) as period1 FROM tblBaseData WHERE iyear = 2005 AND iperiod = 10 AND impactId = 1
SELECT count(impactID) as period1 FROM tblBaseData WHERE iyear = 2005 AND iperiod = 11 AND impactId = 1
What i'd like to do is combine these statements into one which can be run, and name each result with an alias, such as period1, period2, period3...
I have tried to code it but am unsure:-
Code:
SELECT count(impactID), select count(impactID) as period1 FROM tblBaseData WHERE iyear = 2005 AND iperiod = 9 AND impactId = 1 AND supplierId = 1 as period2 iyear = 2005 AND iperiod = 9 AND impactId = 1 AND supplierId = 1
Many thanks,
Alex