O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Scalar Subquery

A scalar row subquery is a single-row subquery. In other words, it returns a single row. If the scalar subquery returns more than one row, it generates an error. The Oracle 9i version has more support of scalar subqueries than Oracle 8i.

FOR EXAMPLE

SELECT city, state, 
      (SELECT count(*) 
         FROM student s 
        WHERE s.zip = z.zip) as student_count 
  FROM zipcode z 
 WHERE state = 'CT' 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required