mysql - How to check in SQL if particular value of a column is appearing more than once -




i trying problem came across have sum sales of particular region , 1 more column needs created result name stores can tell whether particular store in region (east, west, north, , south) or not.

i don't know start these 2 tables , output: enter image description here

in mysql, can achieve result byleft join-ing store_info geography table , group by on column region below. don't need sum separately case again.

 select g.region,        sum(s.sales) sales,        case            when sales > 0 'y'            else 'n'        end stores geography g left join store_info s on s.sn = g.sn group g.region order 2 desc 

result

region  sales   stores ---------------------- west    2050    y east    700     y south   null    n north   null    n 

you can check demo here

hope help.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -