Home » Developer & Programmer » Reports & Discoverer » duplicate rows
duplicate rows [message #257817] Thu, 09 August 2007 04:45 Go to next message
Messages: 4
Registered: August 2007
Junior Member
i have duplicate rows in the database and in the worksheet.
the rows are distinguished by one column.

how can i show only one row of each kind?


Re: duplicate rows [message #257888 is a reply to message #257817] Thu, 09 August 2007 07:38 Go to previous message
Messages: 20847
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If those rows can be distinguished by one column, they are NOT duplicates.

You might try something like this:
SELECT MAX(distinguishing_column), name, address, blabla
FROM this_table
GROUP BY name, address, blabla;

MAX function (or MIN or similar) will force selecting only one of those "distinguishing" columns (you choose which one), but you'll have to GROUP BY all other columns.

Or, you might try
SELECT t.distinguishing_column, t.name, t.address, t.blabla
FROM this_table t
WHERE distinguishing_column = (SELECT MAX(t1.distinguishing_column)
                               FROM this_table t1
                               WHERE t1.primary_key_col = t.primary_key_col

This would require your table to enable joining on primary key column - or columns; in your case, you might need to join ALL columns except 'distinguishing_column'.
Previous Topic: Problem regarding page protect
Next Topic: Set variable as Report header
Goto Forum:

Current Time: Thu Oct 27 14:17:59 CDT 2016

Total time taken to generate the page: 0.10876 seconds