Tuesday, 23 June 2015

SQL Cheat Sheet

SELECT column1, Initcap(column1),to_char(column2,'9.999.99'), column2 * 12 "alias", column3+ 30, add_months(column3,6),to_char(column3, "DD-Month-yyyy HH24:MI:ss"), add_months(to_date('06-january-1988', 'dd-Month-yyyy'),6)  BdayFROM table_name;

Here we fetch
column1, make first letter of column1 capital,
to_char converts to number and formats column2,
column2, multiply it with 12 and give it a name alias, 
column3, adds 30 days
adds_months add 6 months in column3, 
to_char converts date into string and formats it.
to_date converts a string to date and then add_months add 6 months in new column Bday,
from table_name .

Here
column1 is varchar,
column2 is number,
column3 is date,

  

No comments:

Post a Comment