Sql server Distinct Rows

时间:2016-04-25 09:18:05

标签: sql-server-2008-r2

I have a table which contains data use Sql server 2008 r2

+-----+------+--------+-------+------+-------+
| ID  | Kind |  Date  | Price | Type | Amount| 
+-----+------+--------+-------+------+-------+
| 525 |  32  |1/1/2016|  240  |   0  |  3000 |
| 525 |  32  |1/1/2016|  380  |   1  |  3000 |
| 525 |  32  |1/1/2016|  240  |   0  |  4000 |
| 525 |  32  |1/1/2016|  380  |   1  |  4000 |
+-----+------+--------+-------+------+-------+

How can I get this result?

+-----+------+--------+-------+------+-------+
| ID  | Kind |  Date  | Price | Type | Amount| 
+-----+------+--------+-------+------+-------+
| 525 |  32  |1/1/2016|  240  |   0  |  3000 |
| 525 |  32  |1/1/2016|  380  |   1  |  4000 |
+-----+------+--------+-------+------+-------+

1 个答案:

答案 0 :(得分:0)

这不会吗?

SELECT DISTNCT ID, Kind, Date, Price, Type, Amount FROM dbo.yourTable