mysql - Must appear in the GROUP BY clause or be used in an aggregate function (PostgreSQL) -


i have query :

select u.fullname ,s.schedate, sum(case when s.isvisiting =1 s.isvisiting else 0 end) visit , count(s.custid) cust,  sum(case when s.isclosing = 1 s.isclosing else 0 end)as orders  vmstrschedule s join vmsmsuser u on u.usercode = s.salesmanid  u.branchid = 'bll' group u.fullname 

but shows error :

must appear in group clause or used in aggregate function

it works in mysql , when tried in postgresql didn't work . want display data , per month :

enter image description here

but if used query :

select u.fullname,s.schedate, sum(case when s.isvisiting =1 s.isvisiting else 0 end) visit , count(s.custid) cust,  sum(case when s.isclosing = 1 s.isclosing else 0 end)as orders  vmstrschedule s join vmsmsuser u on u.usercode = s.salesmanid  u.branchid = 'bll' group u.fullname,s.schedate order u.fullname 

it shows data :

enter image description here

if "works" mean arbitrarily selects 1 of possible schedate values each group, you're correct. however, postgresql , other sql products want explicit value should select

if values same within each group, putting in either group by clause or arbitrary aggregate (e.g. max(s.schedate)) should work. if values different, please tell server 1 should select - min, or max appropriate.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -