Skip to Content

Whats wrong in this query in SQLScript

Hi,

I want to know Name and city of person (owner) who is having the car with maximum horse power (HP). I'm writing below query for this:

SELECT OWNERID FROM "CLF01"."CAR" WHERE OWNERID = (

SELECT TOP 1 OWNERID, MAX(HP) FROM "CLF01"."CAR" GROUP BY OWNERID ORDER BY 2 DESC );

its giving me error 'too many values'. Inner query is working fine and giving me Ownerid with maximum HP.

Could anybody please help me on this.

Thank you

Add comment
10|10000 characters needed characters exceeded

  • Sorry ! posted wrong query in above post. My query goes like below:

    SELECT NAME CITY FROM "CLF01"."CAR" WHERE OWNERID = (

    SELECT TOP 1 OWNERID, MAX(HP) FROM "CLF01"."CAR" GROUP BY OWNERID ORDER BY 2 DESC );

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 10, 2017 at 07:16 AM

    If you need only the owner(s) with a car with the max. available horse power in the pool I would go with following statement:

    SELECT "NAME", "CITY" FROM "CLF01"."CAR" WHERE "HP" = (SELECT MAX("HP") FROM "CLF01"."CAR");
    Add comment
    10|10000 characters needed characters exceeded