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
 thanks for the fish

Author  Topic 

pureclass85
Starting Member

29 Posts

Posted - 2009-03-07 : 15:30:02
thank you for your help guys!

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-03-07 : 15:52:01
You query is not making any sense. Can you explain what you are looking for?
Go to Top of Page

pureclass85
Starting Member

29 Posts

Posted - 2009-03-07 : 16:03:42
sorry missed a bit

SELECT DISTINCT a.bird_name
FROM expectation a
WHERE (SELECT count(*)
FROM expectation b
WHERE a.bird_name = b.bird_name
AND a.location_name = b.location_name) = 4

basicly it is a compusite query that displays a list of birds spotted 4 times in a location
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-03-07 : 16:05:43
...
FROM Expectation AS a
INNER JOIN (SELECT Bird_Name, Location_Name FROM Expectation GROUP BY Bird_Name, Location_Name HAVING COUNT(*) = 4) AS b
ON b.Bird_Name = a.Bird_Name AND b.Location_Name = a.Location_Name



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

pureclass85
Starting Member

29 Posts

Posted - 2009-03-07 : 16:10:18
thanks peso but it contians a sub query so that means it is composite and i am looking for a way with out using a composite query. thanks
Go to Top of Page

guptam
Posting Yak Master

161 Posts

Posted - 2009-03-07 : 17:58:38
How about ...

SELECT a.bird_name
FROM expectation a
GROUP BY a.bird_name, a.location_name
HAVING COUNT(*) = 4

?

--
Mohit K. Gupta
B.Sc. CS, Minor Japanese
MCITP: Database Administrator
MCTS: SQL Server 2005
http://sqllearnings.blogspot.com/
Go to Top of Page

pureclass85
Starting Member

29 Posts

Posted - 2009-03-08 : 04:26:20
that worked perfect thank you just added distinct
but again thank you
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-08 : 12:43:54
quote:
Originally posted by pureclass85

thank you for your help guys!


why did you delete original question? dont do that as this thread might help somebody else who does face same p-roblem as you
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2009-03-08 : 15:12:37
quote:
Originally posted by pureclass85

i am looking for a way with out using a composite query.


Why? What's wrong with subqueries?

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

- Advertisement -