求一个SQL语句,求两表中同一字段的最大值
两个表A和B都有一个序号字段ID,我想求两个表中的ID字段最大的值,知道一个表中用MAX(ID)就行了,两个表中不知道怎么写 问题点数:40、回复次数:6Top
1 楼scmail81(琳·风の狼(修罗))回复于 2006-02-17 14:33:16 得分 30
select max(id) id
from
(select id from A
union
select id from B) TTop
2 楼mschen(Co-ok)回复于 2006-02-17 14:34:12 得分 10
select max(id) as max_id
from
(
select id from 表A
union all
select id from 表B
) tTop
3 楼dulei115(前途无亮)回复于 2006-02-17 14:35:38 得分 0
select max(a.id) as amaxid, max(b.id) as bmaxid
from a, bTop
4 楼happyflystone(无枪的狙击手)回复于 2006-02-17 14:37:35 得分 0
select max(id) id
from
(select max(id) as id from A
union
select max(id) as id from B) TTop
5 楼wgsasd311(自强不息)回复于 2006-02-17 14:39:36 得分 0
select max(sid) from
(select max(id) sid from a union
select max(id) sid from b)aTop
6 楼lv1(CODER不易做)回复于 2006-02-17 14:41:45 得分 0
多谢多谢Top
相关问题
- oracle中选出某个字段里面最大值的记录的sql语句怎么写?
- 我用sql语句找出了,一个字段的最大值,我应该怎么得到这个值呢?
- 如何在sql选择语句中取出一个日期字段的最大值?
- 求行中的最大值sql语句,,,,
- 请问取数据库某一字段中的记录的最大值的sql语句应该怎么写?例如:字段date (time时间型)
- sql语句查找表中字段varchar类型转numeric类型求最大值的问题(高手帮忙看看)
- 一张表,有如下字段:ID,类型,值。能否用一个SQL语句,得到每种类型的最大值。
- 怎样用select 语句把某字段满足最大值的选择出来
- 怎样得到用SQL语句求最大值的结果?
- 请问一条找最大值的sql语句




