我们假设我们有一个名为Employee的表,列名为'名称':
+---------+
| Name |
+---------+
| Jack |
+---------+
| Paul |
+---------+
| Jack |
+---------+
要拥有不同的名称,我们可以运行此查询:
Select DISTINCT Name
from Employee
还有其他方法可以检索不同的值吗?
答案 0 :(得分:5)
GROUP BY
很愚蠢,但UNION
更糟糕:
select name from Employee
union
select name from Employee
你也可以INTERSECT
...
答案 1 :(得分:4)
我不知道为什么你不想使用distinct,但你可以Series S2 = yourChart.Series.Add("anotherSeriesName");
Series S3 = yourChart.Series.Add("yetAnotherSeriesName");
GROUP BY
如果你只想享受一些乐趣:
Select Name
from Employee
group by Name;
答案 2 :(得分:4)
Select Name
from Employee
Group by Name
这也给出了相同的结果
答案 3 :(得分:0)
;with #temp(Select Name,row_number()over(partition by name order by name desc) as seq)
Select Name from #temp where seq=1