• 周二. 6月 25th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

mysql题目

admin

11月 28, 2021

sql语句考察

题目:请你写出一个sql语句查询在2021-03-10(包含)以后,同一个用户下单2个以及2个以上状态为已支付的面包或可乐或泡面的user_id,并且按照user_id升序排序

表结构如下:

id user_id product status date
1 11 面包 已支付 2021-03-10
2 22 可乐 已支付 2021-03-10
3 33 泡面 已支付 2021-03-10
4 11 可乐 未支付 2021-03-10
5 11 泡面 已支付 2021-03-10
6 22 面包 已支付 2021-03-10
7 11 面包 已支付 2021-03-08

语句:

select * 
from users 
where date >= '2021-03-10'
and status = '已支付'
and product in ('面包','可乐','泡面')
group by user_id // 分组
having count(user_id) >= 2 // 2条及以上

本文来自博客园,作者:alisleepy,转载请注明原文链接:https://www.cnblogs.com/alisleepy/p/15004482.html

《mysql题目》有2个想法
  1. Wow, wonderful weblog format! How lengthy have you been blogging for?
    you make blogging look easy. The total glance of your website is
    excellent, as neatly as the content! You can see similar here
    sklep online

  2. After most mobile phones are turned off, the restriction on incorrect password input will be lifted. At this time, you can enter the system through fingerprint, facial recognition, etc.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注