Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

Get Duplicate Rows In Sql Server

$
0
0

I have table with urls as 2 columns named OriginalUrn , NewUrl and  have duplicate rows with same url and different domains.

For ex:

Amazon.com

http://Amazon.com

https://Amazon.com.

I want these 3 as duplicated and I have googled for a query and found one.But the problem is I'm getting only one column but I want those 2 columns. How could it be done.My code is

SELECT
    CASE
        WHEN CHARINDEX('http://www.corsair.com', OriginalUrL, 1) > 0 THEN SUBSTRING(OriginalUrl, 24, LEN(OriginalUrl) - 23)
        WHEN CHARINDEX('http://gaming.corsair.com', OriginalUrl, 1) > 0 THEN SUBSTRING(OriginalUrl, 27, LEN(OriginalUrl) - 26)
        ELSE OriginalUrl
        End As OriginalUrl
FROM RewriteTable
GROUP BY
    CASE
        WHEN CHARINDEX('http://www.corsair.com', OriginalUrl, 1) > 0 THEN SUBSTRING(OriginalUrl, 24, LEN(OriginalUrl) - 23)
        WHEN CHARINDEX('http://gaming.corsair.com', OriginalUrL, 1) > 0 THEN SUBSTRING(OriginalUrl, 27, LEN(OriginalUrl) - 26)
        ELSE OriginalUrl
    END
HAVING COUNT(*) > 1
I want to show them as duplicate and want to return those urls.How can I do it


Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>