我有下表,我必须从中获取结果行:
id | Course
----+----------------------
39 | B.Sc.-IT-6
40 | B.Sc.-CS/DCS-2
41 | B.Sc.-CS-3
42 | B.Sc.-CS-4
43 | B.Sc.-CS-5
44 | B.Sc.-CS-6
45 | MBA-3
46 | MBA-3
47 | MBA-3
48 | MBA-3
49 | MBA-3
50 | MBA-3
51 | MBA-3
52 | MBA-3
53 | MBA-4
54 | MBA-4
55 | MBA-4
56 | MBA-4
57 | MBA-4
58 | MBA-4
59 | BA-1
60 | BA-2
我想检索只显示一次的重复值,其值为第一个值,如
id | course
----+---------------------
39 | B.Sc.-IT-6
40 | B.Sc.-CS/DCS-2
41 | B.Sc.-CS-3
42 | B.Sc.-CS-4
43 | B.Sc.-CS-5
44 | B.Sc.-CS-6
45 | MBA-3
53 | MBA-4
答案 0 :(得分:0)
试试这个。
<强> QUERY
SELECT MIN(id) AS 'ID',column_name
FROM test
GROUP BY column_name
ORDER BY id;