Please note this is regarding a homework problem, the homework is done and works to the spec, but it's slow so I'm trying to lessen how many SQL calls I make. And I'm still learning my SQL-fu.
My table looks like:
Ticker |Name |Industry
A |Agilent Technologies |Information Technology
AA |Alcoa Inc |Materials
AAPL |Apple Inc. |Information Technology
Right now I am running a SQL statement like this in a loop. Each iteration I change which industry to look at.
SELECT ticker FROM company WHERE industry = 'Information Technology'
But that means I have to make a call to the database for each industry just to get the tickers related to it. What I want is to make one database call that returns multiple results. So the first result would be a list of all the tickers for the first industry, the second result would be all the tickers for the second industry etc.
I tried this SQL, but it just gave me one ticker for each industry, not a full list
SELECT ticker, industry FROM company GROUP BY industry