Cloumn Name, Data type, length, allow nulls:
ID int 4 0
NAAM nvarchar 254 1
DATUM smalldatetime 4 1
Dag int 4 1
Maand int 4 1
Jaar int 4 1
Reenval_Silo float 8 1
Using this table i need to get the average of "Reenval_Silo" per month
for "NAAM " for the years 2006, 2005 & 2004
Any help will be highly appreciated...thnx in advanceHi
Since you have not posted DDL+ sample data + an expected result , I'll give
an idea about how you van do that
--Average of quantity per year group by stor_id
SELECT
stor_id,
AVG(CASE YEAR(ord_date)
WHEN 2004 THEN qty
ELSE 0
END) AS c2004 ,
AVG(CASE YEAR(ord_date)
WHEN 2005 THEN qty
ELSE 0
END) AS c2005 ,
AVG(CASE YEAR(ord_date)
WHEN 2006 THEN qty
ELSE 0
END) AS c2006
FROM Sales
GROUP BY stor_id
ORDER BY stor_id
"amatuer" <njoosub@.gmail.com> wrote in message
news:1160723854.407946.4020@.k70g2000cwa.googlegroups.com...
> Cloumn Name, Data type, length, allow nulls:
> ID int 4 0
> NAAM nvarchar 254 1
> DATUM smalldatetime 4 1
> Dag int 4 1
> Maand int 4 1
> Jaar int 4 1
> Reenval_Silo float 8 1
>
> Using this table i need to get the average of "Reenval_Silo" per month
> for "NAAM " for the years 2006, 2005 & 2004
> Any help will be highly appreciated...thnx in advance
>
No comments:
Post a Comment