SQL-J Language Reference,
Page 45 of 118


[top]
[prev]
[next]
Documentation Top
Global Index
Reference Manual
TOC Index
Grammar index
Developer's Guide
TOC Index
Tuning Cloudscape
TOC Index

ScalarSubquery

You can place a ScalarSubquery anywhere an Expression is permitted. A ScalarSubquery turns a SelectExpression result into a scalar value because it returns only a single row and column value.

The query must evaluate to a single row with a single column.

Sometimes also called an expression subquery.

Syntax

(Query)

Example

-- avg always returns a single value, so the subquery is
-- a ScalarSubquery
SELECT group_id FROM Groups
WHERE budget-running_total >
    (SELECT avg(budget-running_total) FROM Groups)
-- another ScalarSubquery
SELECT hotel_name
FROM Hotels
WHERE city_id = 40 AND normal_rate <
   (SELECT budget-running_total
   FROM Groups WHERE group_id = 1)
[top]
[prev]
[next]


Cloudscape Version 3.0
For technical support, go to: www.cloudscape.com and click Support.
Copyright © 1998 and 1999 Cloudscape, Inc. All rights reserved.