我想顯示一個表中有一個唯一的行,具有相同的值重複行數。我曾嘗試這個sql查詢,從sql數據庫顯示一個唯一的行
select
table1.activityhp, table2.id, table1.sequenceno
from
ServiceDataElementsNew as table1,
VerticalsumNew as table2
where
table1.verticalsumid = table2.id
,並得到了這樣的結果:
activityhp id sequenceno
Total new and repeat acceptors 1 5
Total new and repeat acceptors 1 5
Total new and repeat acceptors 1 5
Total new and repeat acceptors 1 5
Total new and repeat acceptors 1 5
Total new and repeat acceptors 1 5
New acceptors 2 6
New acceptors 2 6
New acceptors 2 6
Repeat acceptors 3 10
Repeat acceptors 3 10
Repeat acceptors 3 10
但我想這一點:
activityhp id sequenceno
Total new and repeat acceptors 1 5
New acceptors 2 6
Repeat acceptors 3 10
感謝您的幫助!
[不良習慣踢:使用舊樣式的JOIN(http://sqlblog.com/blogs/aaron_bertrand/archive/2009/10/08/bad-habits-to-kick- using-old-style-joins.aspx) - 舊式*逗號分隔的表*樣式列表已停用ANSI-** 92 ** SQL標準(超過** 20年前**) –