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

Can you use SQL to eliminate duplicate values in just a single column?

$
0
0

I've got a table that holds line items for items that a customer is paying.  There is a unique field (EntryNumber) and a field that ties all like items together (ItemNumber).  If I query it I may get something like this:

EntryNumber,ItemNumber,Price

1,myitem,1.00

2,myitem,1.00

3,myitem,1.00

4,myitem,0.00

5,myitem,1.00

6,myitem,2.00

The goal would be a query that removes duplicate prices that are sequential.  In other words entrynumber 2 and 3 removed, all else remaining so you would get entrynumbers 1,4,5,6 returned.  Note that not all the price duplicates were removed, 1 and 5 remain in the result because they are separated by 4 having a price of 0.


Viewing all articles
Browse latest Browse all 7129

Trending Articles



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