SQL中的UNIQUE KEYWORD与INNER JOIN

时间:2013-04-03 05:25:53

标签: sql oracle

SELECT S.name, H.pop
FROM HOME H
INNER JOIN STATE S
ON S.name = H.pop
WHERE H.pop >= 10000 ;

我希望这个名字变得与众不同,我尝试了一些不同的东西。但我很难找到解决方案。

任何人都可以帮助我吗?

2 个答案:

答案 0 :(得分:1)

SELECT DISTINCT S.name, S.name AS pop --SINCE BOTH ARE SAME
FROM HOME H
INNER JOIN STATE S
ON S.name = H.pop
WHERE H.pop >= 10000 ;

答案 1 :(得分:0)

是的,我认为J W的评论很好。你可以尝试:

SELECT S.name, sum(H.pop)
FROM HOME H
INNER JOIN STATE S
  ON S.name = H.pop
WHERE H.pop >= 10000 
GROUP BY S.name;

SELECT distinct S.name, H.pop
FROM HOME H
INNER JOIN STATE S
  ON S.name = H.pop
WHERE H.pop >= 10000;