sql - Is there any particular downside to adding MAX() to all fields to weed out duplicate rows? -
i using sql server 2016. have large table 30+ columns. when pull data need there duplicated rows. imagine because there difference in 1 of columns i'm not using, purposes data same. have done change
select [reference], [name], [postcode], [type], [amount] [my table] to
select [reference], max([name]), max([postcode]), max([type]), max([amount]) [my table] group [reference] is cause problems? either in hugely increased processing time or potential errors?
your approach fine. more typical approach is:
select distinct [reference], [name], [postcode], [type], [amount] [my table] t; i expect have same performance group by, can check. sometimes, may optimize differently.
an alternative method is:
select [reference], [name], [postcode], [type], [amount] (select t.*, row_number() on (partition [reference], [name], [postcode], [type], [amount] order (select null) ) seqnum [my table] t ) t seqnum = 1; you might want test , see performs better.
Comments
Post a Comment