【单选题】有订单表tb_order,包含用户信息userid, 商品信息goodsid, 以下()语句能够返回至少被购买两次的商品id。
A. SELECT goodsid FROM tb_order WHERE COUNT(goodsid)>1 B. SELECT goodsid FROM tb_order WHERE MAX(goodsid)>1 C. SELECT goodsid FROM tb_order GROUP BY goodsid HAVING COUNT(goodsid)>1 D. SELECT goodsid FROM tb_order WHERE HAVING COUNT(goodsid)>1 GROUP BY goodsid
A. SELECT goodsid FROM tb_order WHERE COUNT(goodsid)>1 B. SELECT goodsid FROM tb_order WHERE MAX(goodsid)>1 C. SELECT goodsid FROM tb_order GROUP BY goodsid HAVING COUNT(goodsid)>1 D. SELECT goodsid FROM tb_order WHERE HAVING COUNT(goodsid)>1 GROUP BY goodsid
举一反三
- 订单表tb_order包含用户信息uid和产品信息pid等属性列,以下语句能够返回至少被订购过三次的pid是()。 A: SELECT<br/>pid FROM tb_order WHERE count(pid)>3; B: SELECT<br/>pid FROM tb_order WHERE max(pid)>=3; C: SELECT<br/>pid FROM tb_order GROUP BY pid HAVING COUNT(pid)>3; D: SELECT<br/>pid FROM tb_order GROUP BY pid HAVING COUNT(pid)>=3;
- 以下SQL子句的撰写顺序表达正确的是: A: SELECT、FROM、WHERE、GROUP BY、HAVING、ORDER BY B: SELECT、FROM、WHERE、HAVING、GROUP BY、ORDER BY C: SELECT、FROM、WHERE、ORDER BY、HAVING、GROUP BY D: SELECT、FROM、ORDER BY、WHERE、GROUP BY、HAVING
- 有订单表orders,包含用户信息userid,产品信息productid,以下能够返回至少被订购过两次的productid的SQL语句是()。 A: SELECT productid FROM orders WHERE COUNT(productid)>;1; B: SELECT productid FROM orders WHERE MAX(productid)>;1; C: SELECT productid FROM orders WHERE having COUNT(productid)>;1 GROUP BY productid; D: SELECT productid FROM orders GROUP BY productid HAVING COUNT(porductid)>;1;
- 把查询语句的各个子句按执行的先后顺序排列,正确的是( ) A: FROM→WHERE→GROUP BY→SELECT→ORDER BY B: SELECT→FROM→WHERE→GROUP BY→ORDER BY C: WHERE→FROM→SELECT→GROUP BY→ORDER BY D: FROM→WHERE→SELECT→ORDER BY→GROUP BY
- 若要求“查询选修了3门以上课程的学生的学号”,正确的SQL语句是( ) A: SELECT sNo FROM SC GROUP BY sNo WHERE COUNT(*)> 3 B: SELECT sNo FROM SC GROUP BY sNo HAVING COUNT(*)> 3 C: SELECT sNo FROM SC ORDER BY sNo WHERE COUNT(*)> 3 D: SELECT sNo FROM SC ORDER BY sNo HAVING COUNT(*)> 3