小编Ayh*_*aru的帖子

必须出现在 GROUP BY 子句中或在聚合函数中使用 (PostgreSQL)

我有这样的查询:

select u.fullname ,s.schedate,
sum(case when s.isvisiting =1 then s.isvisiting else 0 end) as visit ,
count(s.custid) as cust, 
sum(case when s.isclosing = 1 then s.isclosing else 0 end)as orders 
from vmstrschedule s JOIN vmsmsuser u ON u.usercode = s.salesmanid 
where u.branchid = 'BLL' group by u.fullname
Run Code Online (Sandbox Code Playgroud)

但它显示这样的错误:

必须出现在 GROUP BY 子句中或在聚合函数中使用

它在 MySQL 中可以工作,但是当我在 PostgreSQL 中尝试它时,它不起作用。我想每月显示这样的数据:

在此输入图像描述

但如果我使用这个查询:

select u.fullname,s.schedate,
sum(case when s.isvisiting =1 then s.isvisiting else 0 end) as visit ,
count(s.custid) as cust, 
sum(case when s.isclosing = 1 …
Run Code Online (Sandbox Code Playgroud)

mysql postgresql

2
推荐指数
1
解决办法
1348
查看次数

标签 统计

mysql ×1

postgresql ×1