Created
April 16, 2017 06:41
-
-
Save corean/aa20c14a30bb4cf0655315de4b09bd6b to your computer and use it in GitHub Desktop.
(group by)ML_ID별 Y값 갯수, N값 갯수, P값 갯수
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $query = Plan::with('movie') | |
| ->select( | |
| 'ML_ID', | |
| DB::raw('count(ML_ID) as cnt'), | |
| DB::raw("count(if(PLAN_STAT = 'Y',PLAN_STAT, null)) as Y"), | |
| DB::raw("count(if(PLAN_STAT = 'N',PLAN_STAT, null)) as N"), | |
| DB::raw("count(if(PLAN_STAT = 'P',PLAN_STAT, null)) as P") | |
| ) | |
| ->groupby('ML_ID') | |
| ->havingRaw('count(ML_ID)>0 AND ML_ID != ""') | |
| ->orderby('ML_ID', 'desc'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment