B
B
brar2016-11-14 16:26:20
linux
brar, 2016-11-14 16:26:20

How to select and move rows with duplicate key value to a clean table?

There is a table:

Код;Остаток
00000406;15
00000803;6
00000745;3
00000406; 7

Tell me, please, how can I select rows with a duplicate value of the "Code" field and copy them into a clean table?
Код;Остаток
00000406; 7

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2016-11-14
@brar

INSERT INTO new_table (code, amount)
(SELECT code, amount FROM tabla GROUP BY code HAVING count(*) > 1)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question