select * from user_profile;
select device_id,gender,age,university from user_profile;
查询结果要求去重,在select 后加上distinct 再加上对应的列名
select distinct university from user_profile;
select device_id from user_profile where id<=2;
select device_id as user_infos_example from user_profile where id<=2;
select device_id,university from user_profile where university='北京大学';
select device_id,gender,age,university from user_profile where age>24;
select device_id,gender,age from user_profile where age>=20 and age<=23;
select device_id,gender,age,university from user_profile where university != '复旦大学';
select device_id,gender,age,university from user_profile where age is not null;
select device_id,gender,age,university,gpa from user_profile where gender='male' and gpa>3.5;
select device_id,gender,age,university,gpa from user_profile where university='北京大学' or gpa>3.7;
select device_id,gender,age,university,gpa from user_profile where university='北京大学' || university='复旦大学' || university='山东大学';
select device_id,gender,age,university,gpa from user_profile where (gpa>3.5 and university='山东大学') or (gpa>3.8 and university = '复旦大学');
select device_id,age,university from user_profile where university like '北京%';
select device_id,age from user_profile order by age;
要求先按照gpa升序排序,再按照年龄升序排序输出
所以order by 后 的顺序为gpa,age(默认为升序排序,所以不用加desc)
select device_id,gpa,age from user_profile order by gpa,age;
本题要求降序排序,和37 题的区别是在gpa 和 gpa 的后面加desc(desc的作用就是降序)
select device_id,gpa,age from user_profile order by gpa desc,age desc;