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 |
|
marzipan
Starting Member
10 Posts |
Posted - 2005-11-11 : 16:10:34
|
hi guys, this is my first post, and i know i am a beginner but i really need some help.i have a table in sql 2000.with the following coloumnsEntryID (primary key)RightOrWrong (bit) 1 or 0EntrantsEpost (nvarchar)CompetitionDay (numeric)Answer (nvarchar)bascially the user enters his or her answer each day and if the answer is correct then a 1 would be written, wrong and a 0 would be written.so for example, EntryID RightOrWrong EntrantsEpost CompetitionDay Answer---------------------------------------------------------------------1 1 bob@as.com 1 A2 0 jen@as.com 1 B3 1 bob@as.com 2 C4 1 sam@as.com 2 C5 0 jen@as.com 2 B6 1 bob@as.com 3 A7 1 sam@as.com 3 Bmy problem is that i need to be able to return the results of all users who have got only correct answers for all days.for example,SELECT DISTINCT EntrantsEpostFROM ENTRIESWHERE (RightOrWrong = 1) AND (CompetitionDay BETWEEN '1' AND '3')i can't seen to return the results I need I get either all the users, or all the users who have the correct entries on any of the days.but I need to return the results of the users who have got only correct answers for all days, for example, this would be bob, or using the COUNT, be 1.can anyone help me please?thank you. marthen  |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-11-11 : 16:28:04
|
try this:SELECT EntrantsEpostFROM ENTRIESWHERE (RightOrWrong = 1) group by EntrantsEposthaving count(*) = (select count(distinct CompetitionDay) from ENTRIES) Go with the flow & have fun! Else fight the flow |
 |
|
|
|
|
|