I am using oracle sql developer and I was wondering how you can query the max value of a column where the column has two values that are the max?
For example:
Shapes
square square square triangle circle circle circlewhen i do select max(shapes), it only gives square but not circle even thou开发者_JAVA百科gh both is the max.
May not the best way, but u can try:
SELECT *
FROM (SELECT a.*,
Rank() OVER(PARTITION BY shapes ORDER BY sm DESC) rnk
FROM (SELECT shapes,
SUM(1) OVER(PARTITION BY shapes ORDER BY shapes) sm
FROM shapes_table) a)
WHERE rnk = 1
select Shapes from TableName
group by Shapes
having COUNT(*) = (
select top 1 COUNT(*) from TableName
group by Shapes order by Shapes desc)
This query will give all shapes repeating in that table for maximum times. (This is what I got from your question..)
精彩评论