A table has 150 records. How do you retrieve 100th row to
120th row from that table ?
Answers were Sorted based on User's Feedback
Answer / ajit nayak
select rn, ename
from (select rownum rn, ename
from emp)
where rn between 3 and 7;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sagar sananse
with admitCTE(AdmissionId,PatientId,RN) as
(
select AdmissionId,PatientId,Row_number() over (order by AdmissionId) as RN from tempadmit
)
select * from admitCTE where RN between 101 and 120
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / jayanth
select * from (select a.*, row_number() over (order by empno) rn from emp a) where rn between 100 and 120;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / nancy
select * from (
select tn.*, rownum rd from emp tn ) where rd between 100 and 200;
or
select * From (select tn.* from emp tn where rownum <201
minus
select tn.* from emp tn where rownum <100)
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / manjunath
select level from dual connect by level<=150
minus select from dual connect by level<=120;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sravan
select * from emp where rownum<151
minus(select * from emp where rownum<121)
| Is This Answer Correct ? | 13 Yes | 14 No |
Answer / bhargav
SELECT * FROM
(
SELECT Row_Number() OVER (ORDER BY emp_id, emp_name) as
emp_name
FROM employees
) as a
where rowid >100 AND rowid<121
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / gourav
SELECT * FROM EMPLOYEES
WHERE EMPLOYEE_ID BETWEEN 120 AND 150;
| Is This Answer Correct ? | 2 Yes | 5 No |
Answer / sum
select * from employees where rownum between 100 and 120
| Is This Answer Correct ? | 2 Yes | 15 No |
How to display the contents of a current record fetched in a reference cursor?
What version is sql?
How to place comments in pl/sql?
How many tables can you join in sql?
What is left inner join in sql?
What is the plv (pl/vision) package offers?
What is rownum?
Hi All, I am new to both this blog and technology. I was able to see a response for one of the questions on triggers as below. I would like to know why are we using " if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then" instead, can't we use " if sysdate = 'sunday' then". I can understand the use of "rtrim", but dont know y v r using to_char. I have seen this in many cases but did not get a convincible explaination. Please help me with this and do excuse if this question sounds silly. Thanks in advance...... create or replace trigger trg_sun before insert on <table name> begin if rtrim(to_char(sysdate,'day'))=rtrim('sunday') then raise_application_error(-20345,'no transaction in sunday'); end if; end trg_sun;
Is sql dba a good career? : SQL DBA
what is variable in package specification
When the mutating error will comes? and how it will be resolved?
How to look at the current sql*plus system settings?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)