Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

max(case when …) syntax issue

select 
complaint_id
,complaint_type
,COMMUNICATION_ID
,max(case when delivery_type='deliver_once' then '1' else '0' end as IS_ADDON_REFUND) 
from 
complaints_order_status 
group by 1,2,3

what’s the issue with it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can’t name your column inside the MAX function. Also use integers for 1 and 0. Also, if you could paste in the error message you’re getting it would be helpful. But try:

select complaint_id ,complaint_type ,COMMUNICATION_ID ,max(case when delivery_type='deliver_once' then 1 else 0 end) as IS_ADDON_REFUND from complaints_order_status group by complaint_id ,complaint_type ,COMMUNICATION_ID
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading