1
之間的差I具有下表:檢查是否有兩行
column_a column_b column_c column_d column_date
1 test_1 test_1 type_1 11:00
2 test_2 test_2 type_2 11:01
3 test_3 test_6 type_2 11:02
4 test_4 test_4 type_3 11:03
5 test_2 test_6 type_2 11:04
6 test_1 test_2 type_1 11:05
我要檢查哪個行具有由column_d(類型)過濾在column_b和column_c另一個值。我必須用我的sql腳本分析每種類型的column_date排序的前兩行。 如果其中一列(column_b,column_c或column_d)中的兩行之間存在差異,則必須打印出第一行的值(否則爲空)。
在上面的例子我期待以下結果:
column_a column_b column_c column_d column_date
5 test_2 null type_2 11:04
6 null test_2 type_1 11:05
我可以使用MS SQL服務器的T-SQL 2008
嗨Dalex,感謝很多!而已! :-) – bitsmuggler 2011-12-21 08:56:34