恶补SQL中)牛客SQL题
创始人
2025-05-28 13:39:31

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 2;

SQL5 将查询后的列重新命名

select device_id as 'user_infos_example' from user_profile limit 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;

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;

 SQL36 查找后排序

select device_id,age from user_profile order by age asc;

 SQL37 查找后多列排序

select device_id,gpa,age from user_profile order by gpa asc, age asc;

 SQL38 查找后降序排列

select device_id,gpa,age from user_profile order by gpa desc,age desc;

 SQL11 高级操作符练习(1)

select device_id,gender,age,university,gpa from user_profile where gpa>3.5 and gender='male';

 SQL12 高级操作符练习(2)

select device_id,gender,age,university,gpa from user_profile where gpa>3.7 or university='北京大学';

 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 (gpa>3.5 and university='山东大学') or (gpa>3.8 and university='复旦大学');

 SQL15 查看学校名称中含北京的用户

select device_id,age,university from user_profile where university like '%北京%';

 

相关内容

热门资讯

阿西吧是什么意思 阿西吧相当于... 即使你没有受到过任何外语培训,你也懂四国语言。汉语:你好英语:Shit韩语:阿西吧(아,씨발! )日...
猫咪吃了塑料袋怎么办 猫咪误食... 你知道吗?塑料袋放久了会长猫哦!要说猫咪对塑料袋的喜爱程度完完全全可以媲美纸箱家里只要一有塑料袋的响...
荼蘼什么意思 岁月缱绻葳蕤生香... 感谢作者【辰夕】的原创独家授权分享编辑整理:【多肉植物百科】百科君坐标:云南 曲靖春而至,季节流转,...
demo什么意思 demo版本... 618快到了,各位的小金库大概也在准备开闸放水了吧。没有小金库的,也该向老婆撒娇卖萌服个软了,一切只...
世界上最漂亮的人 世界上最漂亮... 此前在某网上,选出了全球265万颜值姣好的女性。从这些数量庞大的女性群体中,人们投票选出了心目中最美...