Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with this problem sql

Author  Topic 

crosskarl
Starting Member

1 Post

Posted - 2013-02-01 : 05:12:00
I am working with a world database that contains every land, continent, gpd(gross domestic product), population and area. I'm having a problem with writing out continents where every land in the continents gdp is not null. table is named world.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-01 : 06:33:02
[code]
SELECT land, continent, gpd, population ,area
FROM
(
SELECT *,
COUNT(CASE WHEN gdp IS NULL THEN 1 ELSE NULL END) OVER (PARTITION BY continent) AS gdpcnt
FROM world
)t
WHERE gdpcnt=0
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -