-
多值多虑
累计税
查看全部 -
下次学查看全部
-
@MySQL---计算累进税
select user_name,sum(curmoney*rate) as taxmoney from( select user_name,money,low,high, least(money-low,high-low) as curmoney,rate from user1 a join taxrate b on a.money>b.low) a group by user_name
查看全部 -
@MySQL---使用GROUP BY实现多属性查询
select a.user_name from user1 a join user1_skills b on a.id=b.user_id where b.skill in ('念经','变化','腾云','浮水') and b.skill_level>0 group by a.user_name having count(*)>=2;
查看全部 -
@MySQL---使用关联方式实现多属性查询
Select a.user_name,b.skill,c.skill,e.skill From user1 a From user1 a Left join user1_skill b on a.id =b.user_id and b.skill='念经' and b.skill level>0 Left join user1_skill c on a.id = c.user_id and c.skill='变化' and c.skill_level>0 Left join user1_skill d on a.id = d.user_id and d.skill = '腾云' and c.skill_level>0 Left join user1_skill e on a.id = e.user_id and e.skill = '浮水' and e.skill_level>0 Where (case when b.skill is not null then 1 else 0 end) +(case when c.skill is not null then 1 else 0 end) +(case when d.skill is not null then 1 else 0 end) +(case when e.skill is not null then 1 else 0 end)>=2;
查看全部 -
@MySQL---同一属性的多值过滤
方式一
select a.user_name,b.skill,b.skill_level from user1 a join user1_skills b on a.id =b.user_id where skill in ('变化','念经') and skill_skill>0;
方式二
select a.user_name,b.skill,c.skill from user1 a join user1_skills b on a.id=b.user_id and b.skill='念经' join user1_skills c on c.user_id=b.user_id and c.skill='变化' where b.skill_level>0 and c.skill_level>0;
查看全部 -
@MySQL---独有的多例过滤方式
SELECT a.user_name,b.timerstr,kills FROM user1 a JOIN user_kills b ON a.id=b.user_id WHERE(b.user_id,b.kills) IN( SELECT user_id,MAX(kills) FROM user_kills GROUP BY user_id);
查看全部 -
select user_name from user1 where id in (select user_id from user_kills); -- 使用子查询可以避免由于子查询中的数据产生的重复。
select a.user_name from user1 a join user_kills b on a.id =b.user_id; -- 会产生重复记录
select distinct a.user_name from user1 a join user_kills b on a.id =b.user_id; -- 使用distinct去除重复记录
查看全部 -
子杳查询语句:select user_name(列名) from user1(表名) where id in(select user_id(列名)from uers(表名))查看全部
-
子杳查询语句:select user_name(列名) from user1(表名) where id in(select user_id(列名)from uers(表名))查看全部
-
上节没实现查看全部
-
上节没实现 而且左连接不懂查看全部
-
没实现查看全部
-
上节没实现
查看全部 -
未实现
查看全部
举报
0/150
提交
取消