I have following table which saves sales data for specific week of a year.
Sales
week | year | value
50 | 2011 | 150
51 | 2011 | 151
52 | 2011 | 152
1 | 2012 | 170
2 | 2012 | 190
3 | 2012 | 180
4 | 2012 | 160
5 | 2012 | 170
6 | 2012 | 290
I want to find records which lies between week1 of year1 and week2 of year2.
for example
- between week 50 of 2011 to week 5 of 2012
- between week 1 of 2012 to week 6 of 2012
Having little experience in sQL, I tried following query which works for case 2 but not for case 1.
SELECT * from sales WHERE (week >= 1 AND year >= 2012) AND (week <= 6 AND year <= 2012 )
Looks like grouping of condition does not work as I understand. It takes as if there are no grouping of conditions.