0

In case of integers, there are aggregate functions such max, min to find the high and low values in a table.

How to do the same for character type? I mean, If a column as a value repeated more than once, and I want to display that value. How to query that?

for example, I have a table programmer and columns such as programmer, lang1, lang2which has many values in those like programmer column has abu, babu, catherine, david and lang1 column has basic, c, basic, sql and lang2 has pascal, pascal, c, cobol.

My objective is to display the maximum repeated value in lang2 column.

5
  • 1
    Show sample data and desired output Commented Dec 30, 2015 at 7:51
  • Okay. I have a table called program and columns such as programmer, lang1, lang2 and many values entered in those columns. 'lang1' has pascal,pascal,pascal,cobol like values, and I wanna get the result like which language was opted by most of the programmer Commented Dec 30, 2015 at 7:53
  • question is not clear, do you want find rows duplicate column values? Commented Dec 30, 2015 at 8:02
  • i want to extract the maximum repeated value alone. In the above example, it was pascal. Commented Dec 30, 2015 at 8:07
  • 1
    max() and min() will work for character data as well. Edit your question and add some sample data (formatted text please) and the expected output based on that data. Commented Dec 30, 2015 at 9:00

1 Answer 1

1
SELECT lang, COUNT(lang) 
FROM pgm
GROUP BY lang
ORDER BY 2 DESC LIMIT 1

This select query yields maximum repeated language in column lang and its total count

DEMO

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.