Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: HELP NULL

Re: HELP NULL

From: Steve Chandler <schandle_at_us.oracle.com>
Date: Tue, 19 Oct 1999 14:23:54 -0400
Message-ID: <380CB73A.F27797C9@us.oracle.com>


janaskap_at_my-deja.com wrote:

> What happens in the select statement below?
>
> select null
> from xyz;
>
> This is my result. Can someone explain to me what is being retuned?
> N
> -
>
> N
> -
>
> N
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Greetings!

When you perform a SELECT statement what you are doing is retrieving a set of columns, or constants, or aggregation functions (like MAX or SUM) from a set of rows from one or more tables.

The FROM clause defines which tables are used.

The optional WHERE clause defines what subset of rows from those tables participate in the result set. If there is no WHERE clause, all rows are retrieved into the result set.

The optional GROUP BY clause defines how the rows in the result set are grouped for aggregate functions.

The COLUMN LIST defines which columns (or constants or aggregate functions) are shown in the result set.

Your select statement is SELECT NULL FROM xyz;

There is no WHERE clause in your SELECT statement, so you are retrieving every row in the table xyz into the result set.

There is no GROUP BY clause, so you will see one row of output per row in the result set.

The column list which you are retrieving is the special value NULL, which stands in for the absence of value.

So what you are seeing as output is a NULL for each row in xyz.

Try this.

SELECT COUNT(*) FROM xyz;
SELECT rownum, NULL from xyz;

The first select will tell you the number of rows in the table xyz. The second select will show you a "row counter" and NULL for each row. The number of rows you retrieve in the second query should be the same as the number of rows in the table.

If you are trying to retrieve one value, try selecting from the table DUAL, which
is supposed to exist in all Oracle databases, and contain just one row.

Hope this helps.
--
Any opinions expressed in this email are those of the author, and do not

necessarily represent the position of Oracle Corporation

Steven Chandler
Oracle DoD Consulting, Eastern Region Received on Tue Oct 19 1999 - 13:23:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US