I currently have a query in MS Access named Quarterly_Growth_Rates which produces the table below:
Ticker Year Qtr Qtr_Growth
AAPL 2013 3 21.46
AMZN 2013 3 12.59
BBBY 2013 3 4.11
GOOG 2013 3 0.04
V 2013 3 5.13
AAPL 2013 2 -10.27
AMZN 2013 2 4.01
BBBY 2013 2 10.98
GOOG 2013 2 10.74
V 2013 2 7.66
AAPL 2013 1 -20.07
AMZN 2013 1 4.07
BBBY 2013 1 14
GOOG 2013 1 10.39
V 2013 1 10.17
I need to create a CrossTab Query in my VB.net program that will produce this table:
Ticker 2013-3 2013-2 2013-1
AAPL 21.46 -10.27 -20.07
AMZN 12.59 4.01 4.07
BBBY 4.11 10.98 14
GOOG 0.04 10.74 10.39
V 5.13 7.66 10.17
So right now the table shows columns: Ticker, Year, Qtr, and Qtr_Growth a row for every quarter for every year of every ticker.
I need it to show columns Ticker, 2013-1, 2012-4, 2012-3 and only one row for every ticker.
So far I have this code in my program:
Dim cmd4 As OleDbCommand = New OleDbCommand("SELECT Ticker FROM Quarterly_Growth_Rates GROUP BY Ticker PIVOT Qtr ", Nordeen_Investing_3.con)
cmd4.ExecuteNonQuery()
What is the correct SQL statement for this MS Access CrossTab query?