I have a table as shown below:
I need to select columns based on identity_no and also, need to select non zero/non null column values grouped by src_date. so when I query on the identity_no, I want something like:
I need a postgresql statement or even a function is ok. I tried with coalesce. but i can’t do group by on src_date. Here src_date is a string and not a date
Advertisement
Answer
Use group by
and max()
select scr_date,max(upload) as upload, max(download) as download, identity_no, max(email) as email, max(phone) as phone, min(id) as id from tablename group by scr_date,identity_no