Wednesday, June 02, 2010

Oracle SQL Query Formatting - Using the FORMAT command

Query

column "User Counts as of" FORMAT a19;
column "Site 1" FORMAT 99999999;
column "Site 2" FORMAT a10;

select 
 TO_CHAR(SYSDATe,'MM/DD/YYYY HH24:MI:SS') "User Counts as of",
 (select count(*) from v$session) "Site 1",
 (select count(*) from v$session@orcl_site2) "Site 2"
from dual;

Results

User Counts as of       Site 1     Site 2
------------------- ---------- ----------
06/02/2010 10:43:20        600        581

No comments: