Search Postgresql Archives

Re: How to remove duplicate lines but save one of the lines?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Julio Cesar Sánchez González wrote:
A B wrote:
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?

 
You think this would help?
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@xxxxxxxxxxxxx
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
===================================================================


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux