如何從Microsoft SQL Server表中刪除所有重複的月份?刪除重複行查詢結果(Microsoft SQL Server中除外)?
例如,下面的語法我剛剛創建:
SELECT * FROM Cash WHERE Id = '2' AND TransactionDate between '2014/07/01' AND '2015/02/28'
,查詢結果是:
+----+-------------------------+
|Id | TransactionDate |
+----+-------------------------+
| 2 | 2014-07-22 00:00:00.000 |
| 2 | 2014-08-09 00:00:00.000 |
| 2 | 2014-08-25 00:00:00.000 |
| 2 | 2014-08-29 00:00:00.000 |
| 2 | 2015-01-27 00:00:00.000 |
| 2 | 2015-01-28 00:00:00.000 |
+----+-------------------------+
我將如何刪除重複一個月了僅針對任何返回任何值1每個月1個月,如下所示:
+----+-------------------------+
|Id | TransactionDate |
+----+-------------------------+
| 2 | 2014-07-22 00:00:00.000 |
| 2 | 2014-08-09 00:00:00.000 |
| 2 | 2015-01-27 00:00:00.000 |
+----+-------------------------+
你想刪除或只是不選擇它們? – mxix
只是沒有選擇它們,所以不會有重複月份的查詢結果。 – user2731263