[SQL] count, group by, where, like

2023. 8. 16. 09:55SQL

select payment_method, count(*) from orders

group by payment_method

 

kakaopay 56
CARD 218
TAXBILL 4
MONEY 8


select payment_method, count(*) from orders

where course_title = '앱개발 종합반'

group by payment_method

 

kakaopay 34
CARD 111
MONEY 5
TAXBILL 3


select name, count(*) from users

where email like "%gmail.com"

group by name

 

신** 7
이** 29
강** 5
김** 32
심** 3
남** 5
문** 1
손** 1
윤** 3
안** 1
권** 4
박** 7
유** 5
최** 8
황** 4
정** 6
송** 2
한** 2
염** 1
구** 1
임** 2
우** 1
천** 1
장** 2
홍** 2
류** 1
조** 2
채** 1


select course_id, round(avg(likes),1) from checkins

group by course_id

 

5f0ae408765dae0006002817 2.5
5f0ae408765dae0006002816 1.6


select payment_method, count(*) as cnt from orders o

where o.course_title = '앱개발 종합반'

group by payment_method

kakaopay 34
CARD 111
MONEY 5
TAXBILL 3


select payment_method, count(*) from orders

where course_title = '앱개발 종합반'

and email like '%naver.com'

group by payment_method

CARD 38
kakaopay 10
TAXBILL 2

'SQL' 카테고리의 다른 글

[SQL] sub query, case, table  (0) 2023.08.17
[SQL] left join, inner join, group by, order by, count  (0) 2023.08.16