When PostgreSQL's case

Source: Internet
Author: User
Tags postgresql

Select TT.Dict_labelAs Display_item, T1.ratioFrom
(Select T.Product_level,RoundSumCase when T.detect_result=' 2 'Then1Else0End)::numeric/Count1)::NUMERIC,4)As ratio
from T_detect_record t
where t.district= ' 3 ' and t.e_commerce_platform= group by T.product_level) T1
Left JOIN T_dict tt Product_level=tt. dict_value
where Tt.dict_type= ' product_level '


Select Country, sum (case if sex = ' 1 ' then population else 0 End), -- male population

SUM (case if sex = ' 2 ' then population else 0 end) -- female population

from table_a    by country;

 

When PostgreSQL's case

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.