I need to get data between year and period. 1 year have four periods.
i.e; year = 2010 period = 1,2,3,4
the problem is on the period part where i could not select second period smaller from the first period.
for example, i choose year=2010 to year=2011
and period=4 to period=2
the result should display year=2010 period=4,year=2011 period=1,year=2011 period 2. but when i run the code, it returns nothing. however if i choose year=2010 to year=2011 and period=1 to period=4, the code works fine.
here's the example of my code;
SELECT SUM(ma5.alert_value)
FROM company_alert ma5
LEFT JOIN qiddb.company_info mb5 ON (mb5.stock_code=ma5.stock_code)
LEFT JOIN ref_sector mc5 ON (mc5.sector_code=mb5.sector_code)
WHERE ma5.alert_id='VPAEH' AND mc5.sector_code=ref.sector_code AND ma5.year_id BETWEEN '2009' AND '2010' AND ma5.period_id BETWEEN 'q3' AND 'q1'
which part should i fix to make it right? thanks all :)