Volleynerd Knowledge Base

Monday, April 22, 2002


Oracle DateTime Format


Display dates in query output
alter session set NLS_DATE_FORMAT = 'MM/DD/YYYY HH24:MI:SS'

Insert dates into table
insert into foo values ( to_date( '04/01/2002', 'MM/DD/YYYY HH24:MI:SS' ) );


HH hour (1-12)
HH24 hour (0-23)
MI minute
SS second
SSSSS seconds past midnight (0-86399)





SQL GroupBy


Never realized you could get the count and sum of many different columns in a query. The trick is that everything in the "select" clause must be in the "group by" clause. When using the group by, think of it like jamming all those columns together - as long as there's something unique in at least one of the columns, it'll come out as a different group.


select [a,b,c...] , sum(d), sum(e), count(f)
from tableA, tableB
where tableA.ID = tableB.ID
group by [a,b,c...]




Home