Thread: count different values in column?
Hello, today I have a new question :) I've a resulttable is generated by a couple of subselects and joins which contains only one column. Now I want to count the different values in the column. Resulttable : a ------ 10 12 12 12 14 14 15 I need the value which is repeated most in the resulttable (in this example 12 ) ! Any suggestions ? Thx berger
<p>Does the below solve your problem ? <br /> <p><tt>SELECT a from resulttable group by a order by count(a) desc limit1;</tt><br /><tt> a</tt><br /><tt>----</tt><br /><tt> 12</tt><br /><tt>(1 row)</tt><p>regds <br />mallah <br /> <br/> <br /> <p>Thorsten Wenzlaff wrote: <blockquote type="CITE">Hello, <br />today I have a new question :) <p>I've aresulttable is generated by a couple of subselects and joins which <br />contains only one column. <p>Now I want to countthe different values in the column. <p>Resulttable : <br /> a <br />------ <br />10 <br />12 <br />12 <br />12 <br/>14 <br />14 <br />15 <p>I need the value which is repeated most in the resulttable (in this example <br />12 ) ! <p>Anysuggestions ? <p>Thx <br />berger <p>---------------------------(end of broadcast)--------------------------- <br />TIP2: you can get off all lists at once with the unregister command <br /> (send "unregister YourEmailAddressHere" tomajordomo@postgresql.org)</blockquote>