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 |
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-03-01 : 09:39:14
|
| I'm trying to select DISTINCT records, but I keep getting multiple records returned even though I used DISTINCT. The returned records are below the query. I ommitted a couple end columns for ease of reference. Thanks :)_________________________________________________________________SELECT distinct USERS.UserID, miaminewspaper.PropertyPrice, convert(datetime,miaminewspaper.FirstInsertDate), dateadd(day, 30, miaminewspaper.FirstInsertDate)as EndDate, 1, convert (int,AdNumber) as Classified, 0FROM USERS RIGHT OUTER JOINmiaminewspaperON USERS.EmailAddress = miaminewspaper.AdvertiserEmailWHERE miaminewspaper.validAD=1------ Returns -------- Notice UserID repeats for 1 and 2!!UserID Property Price End Date ----------- ---------- ---------1 175600.0000 2006-03-15 1 550500.0000 2006-03-15 2 175600.0000 2006-03-15 2 550500.0000 2006-03-15 3 150000.0000 2006-03-15 4 256666.0000 2006-03-15 (6 row(s) affected) |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-03-01 : 09:56:37
|
| r the columns u removed also repeating along with the given ?What distinct does (from BOL ) : -<<The DISTINCT keyword eliminates duplicate rows from the results of a SELECT statement.>>So if there r other columns in ur select list and if those have different data (ie. if each record is different - they r considered as DISTINCT) |
 |
|
|
gemispence
Yak Posting Veteran
71 Posts |
Posted - 2006-03-01 : 14:45:59
|
| I figured out what it was and it was data related. It turns out that I was inserting 2 records that had the same email. Thanks. |
 |
|
|
|
|
|