日期:2014-05-18  浏览次数:20404 次

关于查询的问题
现有表A  
ID     TEMP       TAXIS
-----------------
1       00SW66   6
2       02SW55   5
3       01SW66   4
4       00SW55   7
5       05SW66   3
6       06SW44   9
7       00SW66   2
8       03SW44   1
9       07SW66   8

我想得到如下结果:
ID     TEMP       TAXIS
-----------------
8       SW44       1
5       SW66       2
2       SW55       5

请问应该怎么写??

------解决方案--------------------
看不懂,顶。
------解决方案--------------------
SELECT [ID],RIGHT(A.[TEMP],4)=,TAXIS FROM tableName AS A WHERE
NOT EXISTS (SELECT 1 FROM TableName AS B ON RIGHT(A.[TEMP],4)=RIGHT(B.[TEMP],4)
AND B.TAXIS> A.TAXIS)

大致的意思就这样,要是语法错误,请大家纠正。

------解决方案--------------------
Select
A.*
From
A
Inner Join
(Select Right(TEMP, 4) As TEMP, Min(TAXIS) As TAXIS From A Group By Right(TEMP, 4)) B
On Right(A.TEMP, 4) = B.TEMP And A.TAXIS = B.TAXIS
Order By TAXIS