SELECT MalzemeBirlesik, MalzemeAd, CAST( sum( Ay1SatisKG) as float) as ay1SatisKG, cast (sum( Ay1IadeKG) as float) as ay1IadeKG,
CAST( sum( Ay2SatisKG) as float) as ay2SatisKG, cast (sum( Ay2IadeKG) as float) as ay2IadeKG,
CAST( sum( Ay3SatisKG) as float) as ay3SatisKG, cast (sum( Ay3IadeKG) as float) as ay3IadeKG,
CAST( sum( Ay4SatisKG) as float) as ay4SatisKG, cast (sum( Ay4IadeKG) as float) as ay4IadeKG,
FROM SKUPerformansSureciAylik GROUP by MalzemeBirlesik order by MalzemeBirlesik ASC
“Ay1SatisKG” is a column name and there are 36 of them and this query will be so long. I want to learn whether there is a way to use for loop with queries? any idea?
The usage (representative) ;
for i=1 to 36
CAST( sum( Ay+i+SatisKG) as float) as ay+i+SatisKG, cast (sum( Ay+i+IadeKG) as float) as ay+i+IadeKG