Question:
How to retrieving the data from 11th column to n th column in a table.
Answer:
select * from emp where rowid in ( select rowid from emp where rownum <=&upto minus select rowid from emp where rownum <&startfrom)
from this you can select between any range. Source: CoolInterview.com
select * from emp where rownum in ( select rownum from emp where rownum <= &upto union select rownum from emp where rownum < &startfrom) Source: CoolInterview.com
Answered by: Soujanya | Date:
| Contact Soujanya
the question is to retrieve the nth COLUMN and not ROW,
i dont have an answer for this, soes any one else have ..? Source: CoolInterview.com
Answered by: bharath | Date: 11/21/2009
| Contact bharath
for column referring number can be used like select 11,12,.. ,n from table
This will retrieve column 11 to nth. Source: CoolInterview.com
Answered by: parag | Date: 1/29/2010
| Contact parag
select * from all_tab_cols where table_name ='tablename' and column_id=11; Source: CoolInterview.com
Answered by: praveen | Date: 2/26/2010
| Contact praveen
limit this is the option used in mysql
select [column name] from table name limit 5,5; here the first 5 specify starting row d next 5 indicates how much row has to be displayed Source: CoolInterview.com
Answered by: mahi | Date: 3/7/2010
| Contact mahi
assuming , we want the data from 11th column ti 15th column :-
SQL> create table fs ( f1 number, f2 number, f3 number, f4 number, f5 number, f6 number, f7 number, f8 number, f9 number, f10 number, f11 number, f12 number, f13 number, f14 number, f15 number) / Table created. ----------------------------- inserting .......... -----------------------------
and then ..
----------------------------- SQL> select 'select '||max(decode(column_id,11,column_name))||','||max(decode(column_id,12,column_name))||','|| max(decode(column_id,13,column_name))||','||max(decode(column_id,14,column_name))||','|| max(decode(column_id,15,column_name))||' from FS;' as query from (select * from user_tab_columns where table_name = 'FS' and column_id between 11 and 15) /
QUERY ---------------------------------- select F11,F12,F13,F14,F15 from FS; ---------------------------------- Copying ...
SQl> select F11,F12,F13,F14,F15 from FS;
.... Source: CoolInterview.com
Answered by: m_nasef | Date: 5/6/2010
| Contact m_nasef
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|