Re: Help with Duplicate Query
From: James Juno (JamesJuno_at_discussions.microsoft.com)
Date: 02/10/05
- Next message: Tom Kaminski [MVP]: "Re: Downloading File located in SQL Server with ASP"
- Previous message: fibreiv: "Downloading File located in SQL Server with ASP"
- In reply to: Hugo Kornelis: "Re: Help with Duplicate Query"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 10 Feb 2005 06:11:09 -0800
Hugo,
Thank you so much. Your suggestion helps a lot.
James
"Hugo Kornelis" wrote:
> On Wed, 9 Feb 2005 15:05:04 -0800, James Juno wrote:
>
> >The problem I have is with the amount column. If all the columns in a row
> >are duplicates and the amount column is between 1 - 100, it considered a
> >duplicate. If the amount column is greater than 100, then it is no longer a
> >duplicate. In other words Amount range between 1 - 100 and everything else
> >is same is duplicate. If everything is same and amount is above 100, it's no
> >longer a duplicate.
>
> Hi James,
>
> Do you mean that these are duplicates:
>
> AA BB 67
> AA BB 59
>
> but these are not:
>
> AA BB 167
> AA BB 159
>
> Further, should these be regarderd as duplicates:
>
> AA BB 167
> AA BB 167
>
> To search for duplicates on all columns except amount for rows with amount
> in the 1-100 range, simply add a where clause "amount between 1 and 100"
> and remove the amount from the group by and select clause.
>
> To find duplicates on all columns, but treating amounts below 100 as equal
> (even if they are not), use something like this:
>
> SELECT Col1, Col2, ...,
> FROM MyTable
> GROUP BY Col1, Col2, ...,
> CASE WHEN Amount < 100 THEN 1 ELSE Amount END
> HAVING COUNT(*) > 1
>
> (untested)
>
> Best, Hugo
> --
>
> (Remove _NO_ and _SPAM_ to get my e-mail address)
>
- Next message: Tom Kaminski [MVP]: "Re: Downloading File located in SQL Server with ASP"
- Previous message: fibreiv: "Downloading File located in SQL Server with ASP"
- In reply to: Hugo Kornelis: "Re: Help with Duplicate Query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|