mysql数据库sql查询语句:多条件判断

 时间:2026-04-23 11:34:23

1、创建测试表,

create table test_person(id int, RMB int);

mysql数据库sql查询语句:多条件判断

2、插入测试数据

insert into test_person values(1,180);

insert into test_person values(2,170);

insert into test_person values(3,290);

insert into test_person values(4,160);

insert into test_person values(5,299);

insert into test_person values(6,266);

insert into test_person values(7,155);

mysql数据库sql查询语句:多条件判断

3、查询表中所有记录,select t.* from test_person t,

mysql数据库sql查询语句:多条件判断

4、编写sql,汇总每个vip类型的用户数,

select vip_type, count(distinct id)

  from (select case when RMB>100 and RMB<200 then 'VIP1' when RMB>200 then 'VIP2' end as vip_type, id

          from test_person) t

  group by vip_type

mysql数据库sql查询语句:多条件判断

  • 利用layui,实现漂亮的复选框
  • jquery如何实现鼠标放上div时改变其大小
  • 如何用python判断目录下是否存在指定文件
  • dbvisualizerSQL语句如何自动提示
  • jquery如何删除子元素
  • 热门搜索
    青岛旅游住宿攻略 关于旅游的诗句 三月底适合去哪里旅游 韩城旅游景点大全 海南文昌旅游 浙江临海旅游 四川古镇旅游景点大全 保定旅游网 浙江诸暨旅游 盐城旅游网