049.牛客SQL之非技术快速入门(230425)


前言

提示:这里可以添加本文要记录的大概内容:

本文章记录了自己撰写牛客网中的SQL题目答案以及不会的地方,以供后续复习使用,太简单的就不写思考过程了,一些不会写的会用黄色标记

并且不能借助datagrip软件,纯手写。


提示:以下是本篇文章正文内容,下面案例可供参考

一、非技术快速入门篇

1.总结

本文的刷题地址为:牛客网MySQL地址-非技术快速入门篇

2.SQL语句

  • 很简单的,easy
-- SQL1 查询所有列
select * from user_profile;

-- SQL2 查询多列
select device_id, gender, age, university from user_profile;

-- SQL3 查询结果去重
select distinct(university) from user_profile;

-- SQL4 查询结果限制返回行数
select device_id from user_profile limit 0, 2;

-- SQL5 将查询后的列重新命名
select device_id as 'user_infos_example' from user_profile limit 0, 2;

-- SQL6 查找学校是北大的学生信息
select device_id,university from user_profile where university = '北京大学';

-- SQL7 查找年龄大于24岁的用户信息
select device_id, gender, age, university from user_profile where age > 24;

-- SQL8 查找某个年龄段的用户信息
select device_id, gender, age from user_profile where age >= 20 and age <= 23;
select device_id, gender, age from user_profile where age between 20 and 23;

-- SQL9 查找除复旦大学的用户信息
select device_id, gender, age, university from user_profile where university != '复旦大学';

-- SQL10 用where过滤空值练习
select device_id, gender, age, university from user_profile where age is not null;

-- SQL11 高级操作符练习(1)
select device_id, gender, age, university, gpa from user_profile
    where gender = 'male' and gpa > 3.5;

-- SQL12 高级操作符练习(2)
select device_id, gender, age, university, gpa from user_profile
    where university = '北京大学' or gpa > 3.7;
  
-- SQL13 Where in 和Not in
select device_id, gender, age, university, gpa from user_profile
    where university in ('北京大学','复旦大学','山东大学');

-- SQL14 操作符混合运用
select device_id, gender, age, university, gpa from user_profile
    where university = '山东大学' and gpa > 3.5 or (university = '复旦大学' 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值