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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Help With Subquery

Author  Topic 

luka
Starting Member

8 Posts

Posted - 2015-02-11 : 12:42:46
Hello, i am new to SQL. I am trying to Show the countries in Europe with a per capital GDP greater than 'United Kingdom'. I have got table world that has countryname,continent,GDP, and area columns. Thx luka

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2015-02-11 : 15:37:27
kind of a general question, but you are basically doing 2 steps, 1st you are identifying the gdp of united kingdom, the you are running a query to give you everything higher

declare @gdp money
set @gdp = (select top 1 gdp from mytable a where a.countryname = 'United Kingdom'
select *
from mytable a
where a.gdp > @gdp
order by gdp desc


Success is 10% Intelligence, 70% Determination, and 22% Stupidity.
\_/ _/ _/\_/ _/\_/ _/ _/- 881
Go to Top of Page

luka
Starting Member

8 Posts

Posted - 2015-02-11 : 15:44:02
Thank you so much.
Go to Top of Page
   

- Advertisement -