简体   繁体   中英

SQL sub queries error

select(select SUM(HOME_SCORE) total from MATCH )
        +
(select SUM(AWAY_SCORE) total from MATCH) 
as "GOALS SCORED"
From dual ;

this is meant to return the sum of HOME_SCORE and AWAY_SCORE I get the following error

Error starting at line : 242 in command - select(select SUM(HOME_SCORE) total from MATCH ) Error report - Unknown Command

Error starting at line : 243 in command - + Error report - Unknown Command

Query Run In:Query Result

Maybe your lacking in parenthesis if you want that way please rewrite your script to this select((select SUM(HOME_SCORE) total from MATCH ) + (select SUM(AWAY_SCORE) total from MATCH)) as "GOALS SCORED" From dual ;

or to simplify this you can try this select(select SUM(HOME_SCORE) + SUM(AWAY_SCORE) total from MATCH ) as "GOALS SCORED" From dual ;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM