Archive for the ‘oracle’ Category

Oracle: auto numbering result (1-based)

February 18, 2011 Leave a comment

This is like adding an auto-incremented column to a query result:

select result.*, rownum from ( select … ) result;

select … is the sub query that doesn’t include the row number. This method is esp. useful when the sub query uses union.

Categories: oracle, sql

Oracle: a quick way to get number of rows using sqlplus

February 18, 2011 Leave a comment

There are times when we need to do some quick test to see if the select query that we build returns reasonable results, here’s a quick solution, type the following into the sql console:
select count(*) from ( select… )

The select… is the query being tested. This is useful when the number of rows returned by select… is huge.

Categories: oracle, sql