I
Islamegy
In y C# project i'm trying microsoft solution to rotate rows as colums
http://support.microsoft.com/kb/175574/EN-US
SELECT YEAR,
Q1= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 1 AND YEAR =
Q.YEAR),0),
Q2= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 2 AND YEAR =
Q.YEAR),0),
Q3= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 3 AND YEAR =
Q.YEAR),0),
Q4= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 4 AND YEAR =
Q.YEAR),0)
FROM QTRSALES Q
GROUP BY YEAR
I can build the Subqueries dynamiclly from code by pass the (Column Alias &
Quarter value) from
pre-query :
SELECT Q_NAME FROM INDECATORS;
and use foreach loop on retrieved rows and replace Q1& Q2...
I want to convert this to one stored procedure so i can pass a YEAR to get
AMOUNT value, is this possible and How??
help plz
http://support.microsoft.com/kb/175574/EN-US
SELECT YEAR,
Q1= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 1 AND YEAR =
Q.YEAR),0),
Q2= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 2 AND YEAR =
Q.YEAR),0),
Q3= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 3 AND YEAR =
Q.YEAR),0),
Q4= ISNULL((SELECT AMOUNT FROM QTRSALES WHERE QUARTER = 4 AND YEAR =
Q.YEAR),0)
FROM QTRSALES Q
GROUP BY YEAR
I can build the Subqueries dynamiclly from code by pass the (Column Alias &
Quarter value) from
pre-query :
SELECT Q_NAME FROM INDECATORS;
and use foreach loop on retrieved rows and replace Q1& Q2...
I want to convert this to one stored procedure so i can pass a YEAR to get
AMOUNT value, is this possible and How??
help plz