Selecting the most common value from relation - SQL statement

Posted by Ronnie on Stack Overflow See other posts from Stack Overflow or by Ronnie
Published on 2010-04-05T23:39:14Z Indexed on 2010/04/05 23:43 UTC
Read the original article Hit count: 408

Filed under:
|
|

I have a table within my database that has many records, some records share the same value for one of the columns. e.g.

|  id  |  name  |  software  |
______________________________
|  1   |  john  |  photoshop |
|  2   |  paul  |  photoshop |
|  3   |  gary  |  textmate  |
|  4   |  ade   |  fireworks |
|  5   |  fred  |  textmate  |
|  6   |  bob   |  photoshop |

I would like to return the value of the most common occurring piece of software, by using an SQL statement.

So in the example above the required SQL statement would return 'photoshop' as it occurs more than any other piece of software.

Is this possible?

Thank you for your time.

© Stack Overflow or respective owner

Related posts about sql

Related posts about select