mysql - Distinct and joins in SQL query? -


i tryint fetch distinct esigndevicecode same device every esigndevicecode new row.

 select       count(distinct(esigndevicecode)) units,      (f.devicename) devicename,      (case when u.status=1  count(u.status) else 0  end) intit,      (case when u.status=2  count(u.status) else 0  end) ekyc,      (case when u.status=4 count(u.status)  else 0  end) esign   applicationdetails u   left join esignlogs e      on e.applicationslno=u.slno    left join fingerprintdevice f     on f.slno=e.deviceid  group e.esigndevicecode; 

your group clause wrong. try this:-

select  count(distinct(esigndevicecode)) units, (f.devicename) devicename, (case when u.status=1  count(u.status) else 0  end) intit, (case when u.status=2  count(u.status) else 0  end) ekyc, (case when u.status=4 count(u.status)  else 0  end) esign  applicationdetails u left join esignlogs e  on        e.applicationslno=u.slno   left join fingerprintdevice f on f.slno=e.deviceid   group devicename, u.status; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -