Click here to Skip to main content
15,921,212 members
Home / Discussions / Database
   

Database

 
GeneralRe: A custom key Pin
Colin Angus Mackay10-Nov-04 6:53
Colin Angus Mackay10-Nov-04 6:53 
QuestionHow to update record Pin
Mekong River9-Nov-04 17:20
Mekong River9-Nov-04 17:20 
AnswerRe: How to update record Pin
Mekong River9-Nov-04 17:46
Mekong River9-Nov-04 17:46 
Generalado and radio button Pin
skicrud9-Nov-04 6:06
skicrud9-Nov-04 6:06 
GeneralRe: ado and radio button Pin
Mekong River9-Nov-04 14:28
Mekong River9-Nov-04 14:28 
GeneralDAO and transactions Pin
calliscope9-Nov-04 5:34
calliscope9-Nov-04 5:34 
Generalusing SQL Distinct Pin
Ahmed Galal9-Nov-04 2:44
Ahmed Galal9-Nov-04 2:44 
GeneralRe: using SQL Distinct Pin
Colin Angus Mackay9-Nov-04 10:42
Colin Angus Mackay9-Nov-04 10:42 
If it is just duplicates in the ID number that you want to eliminate (for this I am assuming you mean eliminate from a select result rather than actually delete the records) then you might want to try something like:

SELECT MyTable.*
FROM MyTable
INNER JOIN (SELECT ID, MAX(TiebreakerColumn) as TiebreakerColumn
            FROM MyTable
            GROUP BY ID) AS SubQuery
    ON  SubQuery.ID = MyTable.ID 
    AND SubQuery.TiebreakerColumn = MyTable.TiebreakerColumn


It really depends on the data you have, especially being able to specify a "tiebreaker column" for the case when you want to remove the duplicates. The tiebreaker column must be unique within the ID and it must be aggregatable (By that that you can use an aggregation function that returns an actual value from the table, like MIN() or MAX(), but not AVG() or SUM())

Does this help?


Do you want to know more?


GeneralRe: using SQL Distinct Pin
Ahmed Galal10-Nov-04 2:11
Ahmed Galal10-Nov-04 2:11 
GeneralSql Error Pin
nacp8-Nov-04 23:24
nacp8-Nov-04 23:24 
GeneralRe: Sql Error Pin
David Salter8-Nov-04 23:26
David Salter8-Nov-04 23:26 
GeneralRe: Sql Error Pin
Mekong River9-Nov-04 14:32
Mekong River9-Nov-04 14:32 
QuestionPrecision and Scale ? Pin
0v3rloader8-Nov-04 4:32
0v3rloader8-Nov-04 4:32 
AnswerRe: Precision and Scale ? Pin
Richard Deeming8-Nov-04 4:45
mveRichard Deeming8-Nov-04 4:45 
GeneralSQLite Pin
Steve S8-Nov-04 0:46
Steve S8-Nov-04 0:46 
GeneralSQL Server Management API Pin
Its due when7-Nov-04 18:33
Its due when7-Nov-04 18:33 
GeneralTrouble in updating source in ADO Pin
wicked_guy7-Nov-04 2:13
wicked_guy7-Nov-04 2:13 
GeneralFrom one database to another (DataSets & .NET) Pin
Jon Rista5-Nov-04 9:28
Jon Rista5-Nov-04 9:28 
QuestionUrgent!!--Layer Isolation using ArrayList?? Pin
obymathew4-Nov-04 23:48
obymathew4-Nov-04 23:48 
AnswerRe: Urgent!!--Layer Isolation using ArrayList?? Pin
Daniel Turini9-Nov-04 0:47
Daniel Turini9-Nov-04 0:47 
GeneralWorking with just time section of a datetime type Pin
Den2Fly4-Nov-04 21:56
Den2Fly4-Nov-04 21:56 
GeneralRe: Working with just time section of a datetime type Pin
Colin Angus Mackay4-Nov-04 22:14
Colin Angus Mackay4-Nov-04 22:14 
GeneralRe: Working with just time section of a datetime type Pin
Den2Fly7-Nov-04 1:45
Den2Fly7-Nov-04 1:45 
GeneralRe: Working with just time section of a datetime type Pin
Colin Angus Mackay7-Nov-04 1:53
Colin Angus Mackay7-Nov-04 1:53 
GeneralRe: Working with just time section of a datetime type Pin
Grimolfr5-Nov-04 9:39
Grimolfr5-Nov-04 9:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.