有这么一个表:
id | name | age | item
1 | tom | 12 | 1
2 | cat | 23 | 2
3 | ... | 36 | 3
4 | ... | 15 | 4
5 | ... | 26 | 2
6 | ... | 16 | 1.......找出 item=3的age 且 其他age小于item=3的age
id | name | age | item
1 | tom | 12 | 1
2 | cat | 23 | 2
3 | ... | 36 | 3
4 | ... | 15 | 4
5 | ... | 26 | 2
6 | ... | 16 | 1.......找出 item=3的age 且 其他age小于item=3的age
你的表达能力实在不是一般..不过我非常人...
select top 1 * from 表名 where item=3 group by age desc
select * from where age <(select age from 表名 where item=3);你的数据只有一条item=3的,如果后面的结果有两条不同的数据.你可以试试select * from 表名 where age <ALL(select age from 表名 where item=3);
对不起大家了,我的语言表达能力问题:
除开item为3的,意思是以item为3的作为参考(但是要排开item为3的),求出其他列里的岁数比item为3的age小的
可行
FROM 表名
WHERE item=3 AND age<(SELECT age
FROM 表名
WHERE item=3)试下这个,能行