I’m trying to find the min(year) and max(year) of a commodity with a given year range (between 2000 and 2015). Then, just displaying the loss percentages of those given years within one row.
New to SQL so I apologise if it is horrendous. Thankyou.
Code
Results
I tried joining the same views, with one searching the MIN(year) of the range and the other searching for the MAX(year). When it runs, it appears generally fine but it’s missing results where the commodity is only in one year. I ran another sql query to find all the commodities in the range and its missing a few (“Beans, dry” and “Other vegetables”).
results of query showing all commodities within the range
cake1921 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.