sql server - Removing Duplicates of two columns in a query -



sql server - Removing Duplicates of two columns in a query -

i have select * query gives lots of row , lots of columns of results. have issue duplicates of 1 column when given same value of column b include 1 of.

basically have column tells me "name" of object , tells me "number". have object "name" more 1 entry given object "number". want distinct "numbers" within "name" want query give entire table when true , not these 2 columns.

name number columnc columnd bob 1 93 12 bob 2 432 546 bob 3 443 76

this illustration above fine

name number columnc columnd bob 1 93 12 bob 2 432 546 bill 1 443 76 bill 2 54 1856

this illustration above fine

name number columnc columnd bob 1 93 12 bob 2 432 546 bob 2 209 17

this illustration above not fine, want 1 of bob 2's.

try if using sql 2005 or above:

with ranked_records ( select *, row_number() over(partition name, number order name) [ranked] mytable ) select * ranked_records ranked = 1

sql-server

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -