score:0
You can do this using the ANSI SQL window function min()
:
select min(id) over (partition by dob) as id, dob
from t;
EDIT:
I'm not quite sure why you would want to set rows to be exact duplicates, but you can do that in a similar way:
with toupdate as (
select t.*, min(id) over (partition by dob) as new_id
from t
)
update toupdate
set id = new_id
where id <> new_id;
More questions
- Change ID to same ID if other value is same
- Copy data to and from the same table and change the value of copied data in one column to a specified value
- Create trigger to insert a column value into other column of same table SQL Server 2005
- SQL create time intervals where other column value is the same
- Update Node Value XML T-SQL Based on Value of Other Node at Same Level
- How to display all the values from one table but on two columns in that table, display the value of other tables if their column name is the same
- Exclude records by values on other records with the same value
- SQL query to extract Dates from table based on the value of other column in the same table?
- Select rows with same ID/email but different value in other table
- In T-SQL, how can I guarantee that a column value is updated only after all other column values in the same UPDATE statement have been updated?
- How to copy a column value to other column of same database table whenever a new record is inserted?
- If 2 rows have the same ID select one with the greater other column value
- Assign Unique Group Id To Sets of Rows with Same Column Value Separated by Other value
- Select rows where all children contain same value only and no other scenario
- SQL Server : getting column values where other column all have same value
- How to update a column with incrementally sequenced values that change depending on other column value
- How do I show one column of data a fix value while the other column is shown normally with both columns from the same column data? SQL
- Error when adding a new column and change the value in the same SQL script
- change the column value as per other column and Serialize value after it in SQL
- SQL Query - Find Value and Get Data From Other Tables Around Same Time
- Update value of one table with other values of same column with different condition in same table
- Does the stream_id change if I move the file to some other directory within the same filetable?
- Repeat the column value until value change in same column value
- SQL statement to change the value of a column with that same column in the where clause
- SQL Server - How to check if a value does not exist in other rows of the same table for same column values?
- How can I fill a column with random numbers in SQL? I get the same value in every row
- Change a Nullable column to NOT NULL with Default Value
- Getting warning: Null value is eliminated by an aggregate or other SET operation
- How to select all rows which have same value in some column
- How to insert one column into other column within the same table in SQL Server
More questions with similar tag
- Changing multiple values in an XML column in SQL Server 2008
- SQL Server Agent not working in SQL Server 2014 Express
- pandas to sql server
- Wrapping system procedure in View or Stored Procedure
- SQL server - use most recent value after replacement
- Inclusion of both inclusive and exclusive range in the same table
- How to filter the String based on , and delete the duplicates
- SQL dynamic running total
- SQL How to return All products sold in last 30 days Include non sellers
- How do I determine if a column is in the primary key of its table? (SQL Server)
- Find available openings using SQL
- table with scope excluded from felloe recursion members
- can you join on a stored procedure?
- How to update a column of a table to a scaling value
- Setting version column in append only table
- Most recent cost value as of date by item
- SQL Server 2008 ssrs multiple records into one
- Deploying database for ASP .NET Website
- Sql Server subscription agent in running state
- Nhibernate: How to find responsible Field for SqlDateTime overflow exception
- Select only the most descriptive rows for each combination of values
- More efficient/elegant way of handling this complicated LIKE statement?
- Unconventional Unpivot and Join
- SQL:How to select data with a comma in the datafield?
- Using SQL Server json properties with code first EF
- Convert varchar "dd/mm/yyyy hh:mm:ss" to datetime2
- SQL Case select
- Architecture Critique: SQL Server FOR XML into XSLT for Rich HTML Interface
- Can changing from datetime to datetime2 ever cause bugs?
- Full-Text keywords unicode
Source:
stackoverflow.com