4. Sample tables (company_id RK companies.id):Companies
id company
1 …
2 …
3 … Locations
id company_id location revision
1 1 … 1
2 2 … 1
3 1 … 2
4 1 … 3
5 2 … 2
6 1 … 4Task: write an SQL query to select values from the following columns (companies.company, locations.location) where locations.revision value will be the highest for each company
id company
1 …
2 …
3 … Locations
id company_id location revision
1 1 … 1
2 2 … 1
3 1 … 2
4 1 … 3
5 2 … 2
6 1 … 4Task: write an SQL query to select values from the following columns (companies.company, locations.location) where locations.revision value will be the highest for each company
解决方案 »
- PostgreSQL 里面有没有像 MySQL 的 SQL_CALC_FOUND_ROWS 一样的功能呢?
- 怎么把.pdm文件导入mysql数据库?
- 在导入表时报ERROR 13 (HY000): Can't get stat of '/root/tab1.sql' (Errcode: 13)
- postgresql 创建分区函数报错
- 大家帮忙看一条sql语句,只能select一部分
- 问一个肯少见的函数参数问题。
- mysql启动问题
- 熟悉C++调用mysql存储过程的看过来!
- 选取记录中姓名相同的记录 并将除了第一条之外的姓名加上星号
- mysql的show status和show global status区别在哪?
- 求一MYSQL触发器代码----自动生成ID-----急
- Netbeans中使用MYSQL的查询语句
from ( Companies c inner join (select company_id,max(revision) as maxrevision
from Locations) m on c.id = m.company_id) inner join Locations l on m.maxrevision=l.revision and m.company_id=l.company_id[align=center]==== 思想重于技巧 ====
[/align]
[/align]