首页 > 试题广场 >

有订单表orders,包含字段用户信息userid,字段产品

[不定项选择题]
有订单表orders,包含字段用户信息userid,字段产品信息productid,以下语句能够返回至少被订购过两次的productid?()
  • select productid from orders where count(productid)>1
  • select productid from orders where max(productid)>1
  • select productid from orders where having count(productid)>1 group by productid
  • select productid from orders group by productid having count(productid)>1
推荐

难度:2

答案:D

知识点:SQL

解析:命令顺序为:select, from, where, group by, having, order by, limit

编辑于 2021-08-30 19:59:11 回复(6)
where不可以直接连接聚合函数
发表于 2020-02-26 12:42:45 回复(5)
使用having语句是因为where无法与计算函数连用
发表于 2020-03-10 18:59:18 回复(6)
having要在group by后面😂😂😂😂😂
发表于 2019-06-08 12:05:15 回复(1)
命令顺序为:select, from, where, group by, having, order by, limit
发表于 2020-03-26 21:52:05 回复(1)
不定项看成多选
发表于 2020-03-12 22:55:30 回复(4)
where不能接聚合函数,因为查询还没有结果,不能用结果对条件进行过滤
发表于 2020-07-19 07:29:22 回复(0)
where不能和聚合函数使用 ,聚合函数是针对结果集进行处理,而where是对结果之前做处理而得出结果集,所以不适合在where中使用结果集
发表于 2021-04-18 22:36:26 回复(0)
where不能跟聚合函数(count,sum)
发表于 2020-08-06 10:07:34 回复(0)
不是多选题吗?选一个还不能提交?
发表于 2022-03-12 11:16:45 回复(0)
where不可以直接连接集合函数
发表于 2020-03-30 20:11:14 回复(0)
C是语法错误,having要在group by 后面
发表于 2020-03-04 12:45:09 回复(0)
此题考察的是Oracle执行的语句过程 from,where,group by,having,select,order by 记忆口诀:服务公还是我(fwghso)
发表于 2021-08-28 10:03:49 回复(1)
<p>为什么A不对,求大神的解释,我比较鸡肋。</p>
发表于 2020-05-19 11:04:14 回复(3)
group by,利用特定条件来分组。
发表于 2019-06-23 14:42:47 回复(0)
where不能和聚合函数在一起使用。having在group by的后面
发表于 2021-11-18 17:00:31 回复(0)
from到表,然后将productid 分组,分组group by 的固定搭配having 过滤----排除A、B  ,分组后过滤使用having将至少购入2次的挑出来,最后select 查询productid即可得到符合题意的答案。注意:使用group by时,查询column_name(字段列名)有非聚合列的时候,分组对象非聚合列(不分组会报错),分组后过滤用having,分组前用where(可以试下,毕竟效率较高,应该能成功)

编辑于 2021-06-04 08:56:23 回复(0)
三短一长选最长。
发表于 2021-05-10 09:34:39 回复(0)
记住where后不能跟聚合函数这题答案就马上出来了,史上做得最快的sql题之一
发表于 2020-05-23 19:45:48 回复(0)
先用group by 分组,再计算数量选择
发表于 2019-09-01 14:24:12 回复(0)
这不是标注的多选题吗?怎么只有一个答案?
发表于 2021-12-07 11:08:27 回复(1)