sql 语句查询

[复制链接]
查看11 | 回复2 | 2010-6-15 15:50:51 | 显示全部楼层 |阅读模式
一张表 games
字段 match_date , record
select * from games得到的结果是
match_date
record
--------------------------
2005-9-5

2005-9-5

2005-9-5

2005-9-5

2005-9-6

2005-9-6

2005-9-6

怎样有sql查询得到结果



2005-9-5
2
2
2005-9-6
2
1
写出sql语句

回复

使用道具 举报

千问 | 2010-6-15 15:50:51 | 显示全部楼层
select match_date,sum(胜) as 胜,sum(负) as 负from(select match_date,case when record = '胜' then 1 else 0 end as 胜,case when record = '负' then 1 else 0 end as 负from games) tbgroup by match_date
回复

使用道具 举报

千问 | 2010-6-15 15:50:51 | 显示全部楼层
select match_date,count(decode(record,胜,1,0)) 胜,count(decode(record,负,1,0)) 负from gamesgroup by match_date;
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行