Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Basic select max problem

User_ICW6QFeb 22 2021

Hello,

I have this kind of table called dbtable

|CITY| |VALUE| |TEXT|
CA 1 caaa
CA 2 cbbb
CA 3 cccc
NY 1 naaa
NY 2 nbbb
NY 3 nccc
NY 4 nddd
BO 1 baaa
BO 2 bbbb
BO 3 bccc
BO 5 bddd
BO 5 beee

I'm trying to get maximum value of city NY with the following select sentence, but its not working. There's no error but it's selecting the max value from all of the values, like it's not using "and city = 'NY' at all
SELECT city, value, text FROM table WHERE value = (SELECT MAX(value)FROM dbtable) and city = 'NY'

Comments
Post Details
Added on Feb 22 2021
12 comments
444 views