Re: How to remove duplicate lines but save one of the lines?
От | Kedar |
---|---|
Тема | Re: How to remove duplicate lines but save one of the lines? |
Дата | |
Msg-id | 48971BFA.6010703@netcore.co.in обсуждение исходный текст |
Ответ на | Re: How to remove duplicate lines but save one of the lines? (Julio Cesar Sánchez González<knowhow@sistemasyconectividad.com.mx>) |
Список | pgsql-general |
Julio Cesar Sánchez González wrote:
create table temp(text varchar(20),id integer );
INSERT INTO temp values('A',10);
INSERT INTO temp values('A',10);
INSERT INTO temp values('B',20);
INSERT INTO temp values('B',20);
INSERT INTO temp values('B',20);
select * from temp;
text | id
------+----
A | 10
A | 10
B | 20
B | 20
B | 20
select text,id, count(1) from temp group by 1,2;
text | id | count
------+----+-------
A | 10 | 2
B | 20 | 3
and forget about the count from the result set.
A B wrote:You think this would help?I have a table with rows like this
A 1
A 1
B 3
B 3
C 44
C 44
and so on.
and I want it to be
A 1
B 3
C 44
so how can I remove the all the duplicate lines but one?
create table temp(text varchar(20),id integer );
INSERT INTO temp values('A',10);
INSERT INTO temp values('A',10);
INSERT INTO temp values('B',20);
INSERT INTO temp values('B',20);
INSERT INTO temp values('B',20);
select * from temp;
text | id
------+----
A | 10
A | 10
B | 20
B | 20
B | 20
select text,id, count(1) from temp group by 1,2;
text | id | count
------+----+-------
A | 10 | 2
B | 20 | 3
and forget about the count from the result set.
-- Thanks & Regards Kedar Parikh Netcore Solutions Pvt. Ltd. Tel: +91 (22) 6662 8135 Mob: +91 9819634734 Email: kedar@netcore.co.in Web: www.netcore.co.in
=================================================================== sms START NEWS to 09845398453 for Breaking News and Top Stories on Business, Sports & Politics. For more services visit http://www.mytodaysms.com ===================================================================
В списке pgsql-general по дате отправления: