Sql Queries:How to convert number into words in oracle using sql query

How to convert number into words in oracle using sql query


select  to_char(to_date(4321,'J'), 'JSP') as word from dual;


Output-FOUR THOUSAND THREE HUNDRED TWENTY-ONE


select  to_char(to_date(123,'J'), 'JSP') as word from dual;


Output-ONE HUNDRED TWENTY-THREE


Above query works only for numbers from 1 to 5373484.


select  to_char(to_date(5373485,'J'), 'JSP') as word from dual;

Output-We get error as "julian date must be between 1 and 5373484"

sql query to drop column


sql query to drop column


alter table tablename drop column columnname;

sql query to rename table name in oracle/rename oracle table


sql query to rename table name in oracle/rename oracle table


alter table oldtablename rename to newtablename

sql query to add new column to table in oracle


sql query to add new column to table  in oracle


alter table tablename add (columname columndatatype)
 

sql query to rename column in oracle/renaming column in oracle


sql query to rename column in oracle



alter table tablename rename column oldcolumn to newcolumn
 

sql query to convert date to mm/dd/yyyy hh:mi:ss including AM/PM


sql query to convert date to mm/dd/yyyy hh:mi:ss including AM/PM.



SELECT to_char(sysdate,'mm/dd/yyyy hh:mi:ss PM')Alias from dual;


output-

11/14/2012 07:56:46 AM

sql query to get 5th record in oracle-how to get 5th record of table in oracle


sql query to get 5th record in oracle



SELECT * FROM tablename WHERE rownum <= 5  MINUS  SELECT * FROM tablename where rownum < 5;

 

sql query to convert date to mm/dd/yyyy hh:mi:ss format -oracle sql queries-to_char function


sql query to convert date to mm/dd/yyyy hh:mi:ss format




SELECT to_char(sysdate,'mm/dd/yyyy hh:mi:ss')Alias from dual;


output-


11/14/2012 07:56:29

sql query to get system date in oracle



sql query to get system date in oracle


select sysdate from dual


output-

14-NOV-12

Sql Query to Retrieve Nth Highest Salary From Table in SQL Server

SQL Server Faqs

SQL Query to find Nth Highest Salary in SQL Server.

SELECT * FROM tablename e1 WHERE N = (SELECT COUNT(DISTINCT (e2.sal))
FROM tablename e2 WHERE e2.sal >= e1.sal)

For example to get 3rd highest salary:
SELECT * FROM emp e1 WHERE 3 = (SELECT COUNT(DISTINCT (e2.sal))FROM emp e2 WHERE e2.sal >= e1.sal)

Similarly to get 2nd highest salary:
SELECT * FROM emp e1 WHERE 2 = (SELECT COUNT(DISTINCT (e2.sal))FROM emp e2 WHERE e2.sal >= e1.sal)

SQL Server Faqs
SQL Query to copy only structure of one table to other table in SqlServer
SQL Query to get structure of table in SqlServer

Movie Songs Lyrics
Software Testing-QTP Scripts,Testing Faqs

How to Retrieve a Random Record from a Table in SqlServer

SQL Query to display a random record from table in sqlserver.

Syntax:Select Top 1 * From tablename Order By NewId()

Example:Select Top 1 * From emp Order By NewId()

Above query will display one random record.

SQL Query to copy structure and data of one table to other in Sql Server.

Software Testing-QTP,Testing Tools,Testing Faqs

Collection of SQL Queries

Recent Posts