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 |
|
nhuot1
Starting Member
1 Post |
Posted - 2012-03-07 : 10:09:43
|
| I'm relatively new to SQL report writing, and I need help.I'm trying to pull all students who have a specific attribute. The problem is that each student has many attributes and even though I specify student_attribute = 'FF07' I get numerous entries (all identical) for each student.How do I only retrieve a single entry for each student?I use this code:select t.id, t.last_name, t.first_name, b.student_attribute,. . .from t, bwhere t.pidm = b.pidmand b.student_attribute = 'FF07'I tried using select distinct t.id, but I get the same results.Any thoughts? |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2012-03-07 : 10:18:14
|
try this:SELECT DISTINCT t.id, t.last_name, t.first_name, b.student_attributeFROM tINNER JOIN bON t.pidm = b.pidmAND b.student_attribute = 'FF07' EDIT: lose your mind reading hat Brett? http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-03-07 : 10:21:07
|
just a shot: duplicate students in table "t" with different idsgarbage in / garbage out No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|
|
|