This is the query I have:
SELECT o.soc_text AS [Occupation Title], COUNT(a.series_id) AS [Records], CONCAT('$',ROUND(AVG(a.value),2)) AS [Average Salary]
FROM occ AS o
LEFT JOIN series AS s
ON o.soc_code = s.soc_code
LEFT JOIN all_data AS a
ON s.series_id = a.series_id
WHERE s.datatype_id_code = 10
GROUP BY o.soc_text, o.soc_code
ORDER BY o.soc_text
It currently takes ~9 seconds, and I need it to take <1 second, and I have genuinely no clue what I'm doing. In my second class at uni that's using sql, and in my first class we learned pretty much nothing about optimizing queries, just learned basic sql commands and stuff; and now in my second sql class we have to optimize a query that's querying like millions of lines of data, and I am quite stuck. Most of that info isn't really relevant, I just felt like complaining.
Anyway, any help would be greatly appreciated, preferably keep it in simple enough terms so I can actually understand it lol.