union的应用
来源:互联网 发布:远程导出oracle数据库 编辑:程序博客网 时间:2024/06/06 10:41
You have just become the database manager for your bookie. He keeps
records on horse races for statistical purposes, and his basic table looks
like this:
CREATE TABLE RacingResults
(track_id CHAR(3) NOT NULL,
race_date DATE NOT NULL,
race_nbr INTEGER NOT NULL,
win_name CHAR(30) NOT NULL,
place_name CHAR(30) NOT NULL,
show_name CHAR(30) NOT NULL,
PRIMARY KEY (track_id, race_nbr_date, race_nbr));
The track_id column is the name of the track where the race was
held, race_date is when it was held, race_nbr is number of the each
race, and the other three columns are the names of the horses that won,
placed, or showed for that race. If you do not know these terms, won
means that the horse was in first place; placed means that the horse was
in first or second place, and showed means the horse was in first,
second, or third place.
Your bookie comes to you one day and wants to know how many
times each horse was in the money. What SQL query do you write for
this?
sql like this:
select a.win_name, count(a.*) from RacingResults r,
(select win_name from RacingResults
union
select place_name from RacingResults
union
select show_name from RacingResults)
as a
where r.win_name = a.win_name
or
r.place_name =a.win_name
or
r.show_name = a.win_name
group by (a.win_name);
- union的应用
- C的union的应用
- SQL SELECT UNION的应用
- union应用
- union 应用
- C++中union的应用剖析
- C++中union的应用剖析
- C++中union的应用剖析
- c++中union的应用剖析
- union中的order by的应用
- union和left join的应用区别
- Sql中Union应用
- union-find 应用
- 对union的进一步认识与一些深层应用
- 巧妙利用union用来判断大小端的应用
- 对union的进一步认识与一些深层应用
- 对union的进一步认识与一些深层应用
- union/union all的用法
- Widows 下的 Hook
- 2010年4月28 - 2010年5月28 学习PetShop的框架和三层结构!
- 航空航天各院所大全
- 怎么解决“只进结果集不支持请求的操作”问题
- windows & python & Emacs
- union的应用
- CUDA在VC2008中的环境搭建与配置要点
- 解决MySQL连接超时Communications link failure due to underlying exception
- 开关电源基础知识
- svn修改用户
- 高端人才必看,生意人必读!
- 深入浅出面向对象分析与设计——学习笔记之二
- VC 统计 代码行数
- 顺流逆流 的 log ,很多不错的关于 动态连接的文章