Page 1 of 1

Report Parameter Query

Posted: Thu Apr 20, 2006 2:35 am
by najm
1 SELECT DEPTNO,DNAME FROM DEPT
2 ORDER BY DEPTNO DESC

DEPTNO DNAME
--------- --------------
40 OPERATIONS
30 SALES
20 RESEARCH
10 ACCOUNTING

i want the Second Highest Deptno on the Top and the others are as it is Which query is Apply there fore the result like this

DEPTNO DNAME
--------- --------------
30 SALES
40 OPERATIONS
20 RESEARCH
10 ACCOUNTING
then i want to show this in a parameter form is it possible

Najm

Posted: Fri Apr 21, 2006 1:43 am
by omerjaved100
Dear,
Here is the work way round to get the required results.

alter table dept add seq_no number;
update dept set seq_no=1 where deptno=30;
select Deptno,DName from dept order by seq_no,deptno desc;

DEPTNO DNAME
---------- --------------
30 SALES
40 OPERATIONS
20 RESEARCH
10 ACCOUNTING NEW YORK

Regards,
M.Omer Javed
ERP Technical Consultant
Mob:+923214647529/ +923004479693

Posted: Fri Apr 21, 2006 4:36 am
by najm
Very Great full for taking intrust but it does not fulfils the requirement i don't want to run any alter/update query becoz for example today i have a dept no 30 on top then after some days it should be deptno 50,80 or any other highest deptno and as on i want dynamic query.

Najm

Posted: Tue Apr 25, 2006 1:32 am
by omerjaved100
select DEPTNO , dname, loc from
(
select dname,DEPTNO , loc ,
rownum sl
from dept order by deptno desc
) order by case when sl=2 then 0 else sl end;

Is it resolves the issue Najam?

Regards,
M.Omer Javed
ERP Technical Consultant
Mob:+923214647529/ +923004479693

Posted: Fri Apr 28, 2006 7:50 am
by najm
Thanks It's Work

Najm