java面试题网

普通会员

217

帖子

75

回复

160

积分

楼主
发表于 2019-05-06 11:24:45 | 查看: 5034| 回复: 0

SQL笔试题:请用sql语句实现表2的查询结果

SQL笔试题:请用sql语句实现表2的查询结果

表1

IDmatchdateresult
12015-02-04
22015-02-04
32015-02-04
42015-04-07
52015-04-07
62015-04-07

表2

比赛日期
2015-02-0421
2015-04-0712

SQL语句:

create table t_second(
matchdate date,
win varchar(3),
lose varchar(3)
);

insert into t_second (matchdate,win) select matchdate,count(result) from t_test where result ='胜' GROUP BY matchdate;

update t_second,(select matchdate,count(result) as lose from t_test where result ='负' GROUP BY matchdate)s set t_second.lose = s.lose where t_second.matchdate = s.matchdate;


文章来自www.wityx.com,转载请注明出处!原文地址http://www.wityx.com/post/786_1_1.html

您需要登录后才可以回帖 登录 | 立即注册

java面试题网www.wuliaokankan.cnjava建站系统提供技术支持V2.1 网站地图 © 2016-2018