SURESHKUMAR.NET FORUMS
Registered Member Login:
Not a member? Register today!



Welcome to the SURESHKUMAR.NET FORUMS.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.




Elite world

        

In this blog I will post all FAQs, code snippets, real time problems and solutions and any other links which I feel every one needs and can take advantage of.
Old

Selecting alternative records in Oracle

Posted 14-10-08 at 09:49 PM by sk_kireeti
Use this logic to select alternative records from a table -

SQL> ed
Wrote file afiedt.buf

1 select * from
2 (select rownum row_num,exec_date from clob_test)
3* where mod(row_num,2)=1
SQL> /

ROW_NUM EXEC_DATE
---------- ---------
1 13-OCT-08
3 13-OCT-08
5 13-OCT-08
7 13-OCT-08
9 13-OCT-08
11 13-OCT-08

6 rows selected....
sk_kireeti's Avatar
Super Moderator
Comments 0 sk_kireeti is offline
Old

Oracle SQL to HTML table

Posted 14-10-08 at 01:06 PM by sk_kireeti
This can be a very handy script if you want to convert a SQL query output into a HTML table.

Execute following anonymous pl/sql block in your SQL*Plus editor -

* Sorry for bad formatting



declare
c number;
d number;
col_cnt integer;
f boolean;
rec_tab dbms_sql.desc_tab;
col_num number;
column_value varchar2(32767);
col_index integer;
sql_query varchar2(32767);...
sk_kireeti's Avatar
Super Moderator
Comments 0 sk_kireeti is offline
Old

SQL to select middle record of a table

Posted 13-11-07 at 11:48 PM by sk_kireeti
A decision has to taken carefully before we implement a solution for the two possibilities -
  1. When we have odd total number of rows
  2. When we have even total number of rows
My SQL will work differently in each case.

In first case (odd number of total rows), this SQL query will return middle record with out any conflict. Eg., If we have 9 records, this will display 5th record from table.

In second case (even number of total rows), this SQL query will return middle two...
sk_kireeti's Avatar
Super Moderator
Posted in Oracle SQL
Comments 1 sk_kireeti is offline
Old

Query to find first and last records of a table

Posted 13-11-07 at 11:34 PM by sk_kireeti
select * from
(select rownum sno, empno,ename from emp)
where
sno =1
or sno=(select count(*) from emp);
sk_kireeti's Avatar
Super Moderator
Posted in Oracle SQL
Comments 0 sk_kireeti is offline

All times are GMT +6.5. The time now is 01:39 AM.

More Interview Questions Here...

Content Relevant URLs by vBSEO 3.3.0