資料內容

欄位 a  b   c   d   e   f

資料 A  B  C  1    2  3

        A  B  C  2    2  3

        D  E  F   7   8  9

        D  E  F   3    4  5

結果  A   B   C   1   2   3

         D   E   F   7   8   9

SQL 如下,如果各位有想到更好的寫法,請告訴我。

select a,b,c,d,e,f from
(select
(select count(*)+1
from table1
where d< a.d
and a+b+c = a.a+a.b+a.c) as cnt,a.a,a.b,a.c,a.d,a.e,a.f
from table1 a) AS TABLEA
WHERE CNT = 1


arrow
arrow
    全站熱搜

    flywang 發表在 痞客邦 留言(0) 人氣()