Table structure is,
Table name: btq_user
name, email, kall, state_id, datain
Now i want to count number records which has kall = 1 or state_id in( 51, 20, 46) by weekly. i need the results only by weekly (Mon - Sun) no matter if year changes. lets say for example 31-12-2012 is Monday and 6-1-2013 is Sunday so result should include that as a week. no matter if year changes it should count only with weeks.
This is what i tried but not working.
SELECT
count( if( A.state_id = 51 or A.state_id = 20 or A.state_id = 46, A.state_id,
null ) ) AS state_total, count( if( A.kall =1, A.kall, null ) ) AS appointment,
CONCAT( WEEK( A.datain) , " -
", YEAR( A.datain ) ) AS week
FROM btq_user A
GROUP BY week
ORDER BY A.datain ASC
also is there any possibility to display weeks ( 31-12-2012 - 6-1-2013 ) with results ?
Thank you for reading my question.