0
I did it in a code where it makes a sum of data entered in the months,
but I don’t know how to make the AS
become a array
.
The Code I made:
DECLARE @I INT = 1;
WHILE @I < 12
BEGIN
SELECT SUM(valueEarn) AS monthValue1
FROM earnAccount
INNER JOIN bankAccount ON bankAccount.idBankAccount = 1
WHERE MONTH(dateEarnCreate) = @I
SET @I += 1
END
as it turned out:
As you can see it returns me the same column name monthValue1
, wanted it to be generated from monthValue1
to monthValue12
,pq then I will take this data to put on a graph.
wanted something like this:
Put the table structure used in select. and explain the rule in more detail than you need.
– Lodi
This answers your question? Help with a PIVOT ( Sql Server )
– Sorack