Why this query is not returning data of 2011 and 2012. Can anyone help me out.Thanks in advance.
SELECT country_code, SUM(`attendance`) as k6_attendance, count(*) as total_events , IF(MONTH(`session_date`)<5,YEAR(`session_date`),YEAR(`session_date`)+1) as YR2 FROM `v_knowledge_session` v WHERE session_date >0 Group by YR2,country_code HAVING YR2>(YEAR(NOW())-2) AND country_code='IN' ORDER BY country_code,YR2;
session_dateandcountry_codefrom the table.DESCRIBE v_knowledge_session;and some sample data and expected output?WHEREclause seems to me to be too shabby.