QUESTION #1:
I have been playing with the SELECT command you showed me and I don't understand why the COUNT(*) and the HAVING clause are needed in it. I get the same results (unique records) if I do the following two commands:
SELECT count(*),* FROM mytable GROUP BY field1,field2,field3 HAVING COUNT(*)>1
-or-
SELECT * FROM mytable GROUP BY field1,field2,field3
Do you think this is right or am I missing something?
QUESTION #2:
About to copy the records... I am looking for a SELECT command to give me the DUPLICATE records also. The first one was to display the unique records, now I want another command to display the duplicate ones.
I can do it with a bunch of commands not SELECT - SQL but I think there should be a way to do it, I just don't know how.
Thank you again.
>Not sure what your asking. If you wantto save the results to a table, you can use
>
>COPY TO c:\mytable
>
>
>>Thank you for your time, that command is working great. Now, is there an easy way to save the dup records in this table using a SELECT command?
>>
>>>>Hello Erik,
>>>>The real table has 70 fields. Do I have to specify the 69 fields in the GROUP BY clause?
>>>>
>>>>>>I have a table with 5 fields and I'd like to get rid of the dup records base of 4 fields. The SELECT DISTINCT command doesn't work in this case because it compares the whole record.
>>>>>>
>>>>>>Any sugestions? Thank you in advance.
>>>>>
>>>>>you can choose your criteria for your uniqueness check with the GROUP BY clause:
>>>>>
>>>>>SELECT COUNT(*), * FROM Mytable GROUP BY Field1, Field2, Field3, Field4 HAVING COUNT(*) > 1
>>>
>>>The group by clause contains only the fields you want to use to determine uniqueness. If you are basiing your definition of uniquness on the contents of 4 fields, put those for fields in the GROUP BY clause.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only