0
我需要OP10上的數據第一次輸入的開始時間和最後一次輸入的結束時間。(OP10開始時間:上午10點和結束時間:上午11點10分)。與明智的OP20和OP30類似。爲避免同一數據的多個報告(OP10),給我ITS啓動&結束時間就夠了。如何使用SQL中的過濾數據獲取內部連接查詢?
SQL表結果:
+---------+------------+-----------------------------+-----------------------------+
| Line Operation | StartDate | EndDate |
+---------+------------+-----------------------------+-----------------------------+
| ACOE | OP10 | 2017-01-27 10:00:00.000 | 2017-01-27 10:10:00.000 |
| ACOE | OP10 | 2017-01-27 11:00:00.000 | 2017-01-27 11:10:00.000 |
| ACOE | OP20 | 2017-01-27 11:10:00.000 | 2017-01-27 11:15:00.000 |
| ACOE | OP20 | 2017-01-27 11:20:00.000 | 2017-01-27 11:25:00.000 |
| ACOE | OP30 | 2017-01-27 12:10:00.000 | 2017-01-27 12:15:00.000 |
| ACOE | OP30 | 2017-01-27 12:20:00.000 | 2017-01-27 12:25:00.000 |
+---------+------------+-----------------------------+-----------------------------+
需要輸出類似如下格式:
+---------+------------+-----------------------------+-----------------------------+
| Line Operation | StartDate | EndDate |
+---------+------------+-----------------------------+-----------------------------+
| ACOE | OP10 | 2017-01-27 10:00:00.000 | 2017-01-27 11:10:00.000 |
| ACOE | OP20 | 2017-01-27 11:10:00.000 | 2017-01-27 11:25:00.000 |
| ACOE | OP30 | 2017-01-27 12:10:00.000 | 2017-01-27 12:25:00.000 |
+---------+------------+-----------------------------+-----------------------------+
但是使用內部連接查詢這種語法StartDate = MIN(StartDate),EndDate = MAX(EndDate)拋出錯誤。 – Dhamo
sintax我寫信給你它可以...你可以發佈你的完整查詢嗎? – DarioN1