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.
| 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? |
 |
|
|
pureclass85
Starting Member
29 Posts |
Posted - 2009-03-07 : 16:03:42
|
| sorry missed a bitSELECT DISTINCT a.bird_nameFROM expectation aWHERE (SELECT count(*)FROM expectation bWHERE a.bird_name = b.bird_nameAND a.location_name = b.location_name) = 4basicly it is a compusite query that displays a list of birds spotted 4 times in a location |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-03-07 : 16:05:43
|
...FROM Expectation AS aINNER JOIN (SELECT Bird_Name, Location_Name FROM Expectation GROUP BY Bird_Name, Location_Name HAVING COUNT(*) = 4) AS bON b.Bird_Name = a.Bird_Name AND b.Location_Name = a.Location_Name E 12°55'05.63"N 56°04'39.26" |
 |
|
|
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 |
 |
|
|
guptam
Posting Yak Master
161 Posts |
Posted - 2009-03-07 : 17:58:38
|
| How about ...SELECT a.bird_name FROM expectation aGROUP BY a.bird_name, a.location_nameHAVING COUNT(*) = 4?-- Mohit K. GuptaB.Sc. CS, Minor JapaneseMCITP: Database AdministratorMCTS: SQL Server 2005http://sqllearnings.blogspot.com/ |
 |
|
|
pureclass85
Starting Member
29 Posts |
Posted - 2009-03-08 : 04:26:20
|
| that worked perfect thank you just added distinctbut again thank you |
 |
|
|
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 |
 |
|
|
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 ShawSQL Server MVP |
 |
|
|
|
|
|