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
 SQL Query Doubt

Author  Topic 

santhoshcool123
Starting Member

4 Posts

Posted - 2012-03-09 : 06:20:14
Hi, I am just a beginner to SQL queries. I am facing a bit trouble writing queries for this table.

PID STATE CITY YOB POP
---- ---------- ---------- ---------- ----
101 KAR BAN 1990 2C
102 KAR BAN 1990 3C
103 KAR BAN 1990 4C
104 KAR BAN 1991 3C
105 KAR MYS 1991 6C
106 AP HYD 1991 4C
107 TN CHEN 1991 9C
108 TN CHEN 1993 3C

a. Display states that are having more than 5C population
b. Display population w.r.t. State, City, and population
c. Display city wise number of persons only if the total population is more than 1C excluding Kar and AP. The output should also not include years between 1990-1992,

Thanks for the help

jimoomba
Yak Posting Veteran

90 Posts

Posted - 2012-03-09 : 07:11:37
could you please be more specific on questions b and c

rams
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2012-03-09 : 07:57:09
Homework? If so, post what you've tried and explain where you are stuck.

We don't do people's homework for them.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-09 : 11:25:47
quote:
Originally posted by santhoshcool123

Hi, I am just a beginner to SQL queries. I am facing a bit trouble writing queries for this table.

PID STATE CITY YOB POP
---- ---------- ---------- ---------- ----
101 KAR BAN 1990 2C
102 KAR BAN 1990 3C
103 KAR BAN 1990 4C
104 KAR BAN 1991 3C
105 KAR MYS 1991 6C
106 AP HYD 1991 4C
107 TN CHEN 1991 9C
108 TN CHEN 1993 3C

a. Display states that are having more than 5C population
b. Display population w.r.t. State, City, and population
c. Display city wise number of persons only if the total population is more than 1C excluding Kar and AP. The output should also not include years between 1990-1992,

Thanks for the help



hints

a.use filter condition using > operator
b. use GROUP BY including state,city
c. filter on years outside 1990-1992
GROUP BY city
filter on count of persons for population > 1c

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

Go to Top of Page
   

- Advertisement -