Skip to content
Advertisement

Missing expression inside sub-query statement?

I am using the infamous “CityJail” schema to answer a question “List the names of all criminals who have committed more than average number of crimes and aren’t listed as violent offenders.”

Here is my code:

but I get an error:

ORA-00936: missing expression 00936. 00000 – “missing expression” *Cause:
*Action: Error at Line: 7 Column: 22

When I change my code to:

I get an error:

ORA-01787: only one clause allowed per query block 01787. 00000 – “only one clause allowed per query block” *Cause:
*Action: Error at Line: 8 Column: 1

What am I doing wrong?

criminals:

crimes:

Advertisement

Answer

Fix Your Scalar Subquery in the Having Clause

The scalar query is malformed in both of your attempts.

I moved the condition WHERE v_status = 'N' to the main query (you are only concerned about criminal whom are non-violent).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement