这条sql语句对吗?

freedonn 发布于 2015/06/04 22:54
阅读 215
收藏 0

select a.mac,a.add_date,count(a.mac) as num from wifi_authlist a inner join wifi_shop s on a.shopid = s.id where s.id in (select id from wifi_shop where pid=3) and a.add_date = '2015-06-04' group by a.mac;

看着网上说select中的字段要么出现在聚合函数中,要么出现在group by的后面,可是我的这条sql语句也没有报错啊,我自己都迷糊了,请教大神!

加载中
0
瞌睡来了
瞌睡来了

没什么不对


0
一心二影
一心二影

错了 group by a.mac,a.add_date 看你是要看一天的还是怎么?

如果时间是固定的也可以 改成 :

select a.mac,'2015-06-04' add_date,count(a.mac) as num from wifi_authlist a inner join wifi_shop s on a.shopid = s.id where s.id in (select id from wifi_shop where pid=3) and a.add_date = '2015-06-04' group by a.mac;

0
秋豪的爸爸
oracle还是mysql?group by时的语法是不一样的
freedonn
freedonn
我这是mysql的,这样写有问题吗?
0
maradona
maradona
你这是mysql? 偶尔用一下,记不清楚,好像不会错,但oracle应该会报错
freedonn
freedonn
我这是mysql的
0
逆流de鱼
逆流de鱼
select a.mac as num from wifi_authlist a inner join wifi_shop s on a.shopid = s.id where s.id in (select id from wifi_shop where pid=3) and a.add_date = '2015-06-04' group by a.mac;oracle中聚合用到了聚合函数则查询结果中只能返回被聚合函数影响的函数
freedonn
freedonn
我这是mysql
返回顶部
顶部