-
Case and decode
can anyone help with a simple example of converting one from other like CASE to DECODE or DECODE to CASE.
-
Display Odd/ Even number of records
Odd number of records:select * from emp where (rowid,1) in (select rowid, mod(rownum,2) from emp);Output:-135Even number of records:select * from emp where (rowid,0) in (select rowid, mod(rownum,2) from emp)Output:-246
-
What is use of a cursor variable? How it is defined?
A cursor variable is associated with different statements at run time, which can hold different values at run time. Static cursors can only be associated with one run time query. A cursor variable is reference type (like a pointer in C).Declaring a cursor variable:TYPE type_name IS REF CURSOR RETURN return_type type_name is the name of the reference type,return_type is a record type indicating the...
-
Open a Excel File directly from SQL command line
How to open an excel sheet directly from the SQL prompt?
Oracle query performance
A) I have 100 columns in emp table , which of the below queries will give good performance and WHY?1) Select * from emp;2)select col1,col2,col3,..............col100 from emp;B) we have 2 tables T1(100 records) and T2(1000) recordsWhen we use the below queries , it will generate Cartesian product , which query will give better performance and WHY?1)Selct * from t1,t2 ;2)select * from t2,t1;
Difference between procedure and function.
Functions are named PL/SQL blocks that return a value and can be called with arguments procedure a named block that can be called with parameter. A procedure all is a PL/SQL statement by itself, while a Function call is called as part of an expression.
Pluks and Zinks
There is a table with pluks and zinks. Each pluk only resides on a single zink and each zink may contain multiple pluks. How do you find how many pluks are on each and every zink?
Index Use
If you have a three columns table with one index on 2nd Column. In the SELECT statement you retrived column 1, can index be used or not?
Display Mth to Nth Column in a Table
How to display data in the table between mth column to nth column in a table in Oracle?
Random Records
Write a SQL query to select 10 random records from a table?
SQL Query to retrieve columns having a particular character
Table StructureID Name Salary1 Pratap 15002 Gayathri 25003 Anita 3000 4 Ram.C 4500Write a query to retrieve names which have the letter R in it irrespective of the case(small or caps).Output:ID Name Salary1 Pratap 15002 Gayathri 25004 Ram.C 4500
Replace and Translate
How and in what way REPLACE is different from TRANSLATE?
Ans