Converting Date to String in Excel
=TEXT(B2,”m/d/yyyy h:mm AM/PM”)
November 12, 2009
Converting Date to String in Excel
=TEXT(B2,”m/d/yyyy h:mm AM/PM”)
November 3, 2009
A great overview and intro to Oracle
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/toc.htm
November 3, 2009
http://www.dbasupport.com/oracle/ora10g/model.shtml
B10736-01 Oracle Database Data Warehousing Guide, Chapter 22
October 22, 2009
The Set Operators (Union, Intersect & Except) provide some very powerful functionality in SQL and are often the building blocks of complex SQL queries. When you understand what they do and when to use them, it greatly aids your understanding of SQL.
The following below is a summary of a great explanation I found at: http://publib.boulder.ibm.com/infocenter/rbhelp/v6r3/index.jsp?topic=/com.ibm.redbrick.doc6.3/sqlrg/sqlrg42.htm
UNION, EXCEPT, INTERSECT
…All operate on multiple result sets to return a single result set:
INTERSECT computes a result set that contains the common rows from two result sets.
UNION, INTERSECT, and EXCEPT operators can be combined in a single UNION expression.
In statements that include multiple operators, the default order of evaluation (precedence) for these operators is left to right; however, the INTERSECT operator is evaluated before UNION and EXCEPT. The order of evaluation can be modified with parentheses.
The following figure illustrates these concepts with Venn diagrams, in which the shaded portion indicates the result set.
Figure 4. Result Set

Venn Diagrams - Set Operators
Examples:
The following example replaces the UNION operator with EXCEPT; consequently, only those California cities that are in the Market table but not the Store table are returned:
select hq_city as ca_cities
from market
where hq_state like 'CA%'
except
select city
from store
where state like 'CA%'
CA_CITIES
Oakland
San Francisco
The following example replaces the UNION operator with INTERSECT; consequently, only those California cities that are in both the Market table and the Store table are returned:
select hq_city as ca_cities
from market
where hq_state like 'CA%'
intersect
select city
from store
where state like 'CA%'
CA_CITIES
Los Angeles
San Jose
select prod_name from product natural join sales_canadian union all (select prod_name from product natural join sales_mexican union select prod_name from product natural join sales)
(select prod_name from product natural join sales_canadian union select prod_name from product natural join sales_mexican) intersect select prod_name from product natural join salesThe following query uses multiple INTERSECT operations to return a list of common key values in five different tables:select prodkey as common_keys from product intersect select classkey from class intersect select promokey from promotion intersect select perkey from period intersect select storekey from store COMMON_KEYS 1 3 4 5 12
October 22, 2009
Example 1:
October 19, 2009
from
http://www.howtodothings.com/computers/how-to-use-formatting-in-oracle-sql
–>
Once you retrieve your data, you should think about how you would like to view it. You can do a lot of formatting in Oracle SQL, which translates into saved time for you. After all who wants dirty data?
Formatting is a presentation issue. It allows you to present the data you have gathered so that it looks good. And as someone once said, “Perception is key.” I use the following 8 formatting tricks. There are many more, but the ones below are essential to know.
SELECT SYSDATE, ROUND(SYSDATE, ‘Wed’),
TRUNC(SYSDATE, ‘Wed’)
FROM u.agg_ia_clickstream
SYSDATE ROUND(SYSDA TRUNC(SYDATE
————– ————————————————
31-Dec-2003 01-Jan-2004 01-Dec-2003
Rounding allows the date to be rounded up to the nearest month. Truncation allows the date of any value you specify to its minimum. The minimum value is 1, so 31-Dec was truncated to 1-Dec.
REPLACE(string, search, replace)
SUBS(STRING, START[, length])
LENGTH(string)
String1 ll String2
Trim(string)
Trim(character FROM string)
To trim only characters to the right:
RTRIM(string)
To trim characters only to the left:
LTRIM(string)
To remove punctuation from both sides of a string:
RTRIM(LTRIM(string,’.;!’),’.,!’)
To Change letters to upper case letters:
UPPER(string)
To change letters to lower case letters:
LOWER(string)
To use upper case for the first letter and lower case for other letters:
INITCAP(string)
SELECT date, unique cookies
DECODE (dma, 360, ‘Dayton’, 560, ‘Toledo’, 870, ‘Baton Rouge’, Null, ‘Unknown’)
FROM u.agg_ia_clickstream
In this example, 360 is replaced by Dayton, 560 is replaced by Toledo, etc.
The 8 formatting tips above will help you make your data — and hopefully you, by association — look good. If you know other tips that are helpful, please let me know. Thank you for reading.
October 18, 2009
select userid, max(case recordtag when 1 then record end) as firstname, max(case recordtag when 2 then record end) as middleinitial, max(case recordtag when 3 then record end) as suffix from [YourTable] group by userid
October 8, 2009