php - Select row that has similar name -



php - Select row that has similar name -

so have tbl_total this.

name | total | month ========================= david | 87 | jan mike | 67 | jan david | 90 | feb mike | 100 | feb

and want display this. please tell me how coz i've no thought @ how display in php.

name | jan | feb =================== david | 87 | 90 mike | 67 | 100

select name, sum(case when month = 'jan' total else 0 end) jan, sum(case when month = 'feb' total else 0 end) feb, sum(case when month = 'mar' total else 0 end) mar, sum(case when month = 'apr' total else 0 end) apr, sum(case when month = 'may' total else 0 end) may, sum(case when month = 'jun' total else 0 end) jun, sum(case when month = 'jul' total else 0 end) jul, sum(case when month = 'aug' total else 0 end) aug, sum(case when month = 'sep' total else 0 end) sep, sum(case when month = 'oct' total else 0 end) oct, sum(case when month = 'nov' total else 0 end) nov, sum(case when month = 'dec' total else 0 end) `dec` your_table grouping name

php mysql select

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -