Using ORDER BY in Oralce 7.3.x
Hi,
I need to create a view using ORDER BY cluase in Oralce 7.3.x.
(I guess ORDER BY Clause is not supported in Oracle 7.3).
Please Let me know any workaround for this.
Thanks in advance.
-Gopi
Have you tried a simple select statement using ORDER BY? ORDER BY is definitely supported in 7.3.
I haven't written a VIEW using ORDER BY, but what I remember most about VIEWS is that you have to use COLUMN ALIASES when referencing them in other statements. Maybe you need to assign column aliases and then peform the order by.... I don't know this for sure though.
PS views are slow enough as it is. Why not just select the data through the view, and then when you run queries off of the view, then perform the ORDER BY?
Similar Messages
-
Sorting of Date field in the SQL Query useing ORDER BY
Hi
I am facing a problem when I am getting the results of a query from the ORacle 8i database using jdbc connection.
The query is having a date field and I have to sort the query results using ORDER By for the Date field. The query is giving exact results in the SQL PLus interface.
When I am getting this results in the GUI where servlets are being used an Exception is coming as not supported RefreshRow method.
If anyone has faced this problem and have got the solutions please let me know.
thanks
sulfyThat doesn't sound at all like an SQL problem.
More like you trying to do updates on the resultset which is not allowed ...
send a some code (not to much pls :) and we'll be
able to help more
cu
Spieler -
How can i use Order by inside a sub query in Oracle
Hi!,
Please help me, it's an urgent... how can i use Order by clause
SELECT SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.dDate
, (SELECT nvl(S.Qty,0) FROM Stock S , DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.dDate <= DD.dDate and rownum=1
ORDER BY DD1.dDate DESC*) as StockQty
, (SELECT nvl(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.dDate > DD.dDate
AND DD2.dDATE=DD.dDate
) as TotalQtySold
FROM SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0;
kindly help
Thank you.Actually I'm converting Procedures from SQL Server to Oracle.
Actual Stored Procedure in SQL Server is as follows.
SELECT --top 10000
SalesProductKeyID,ActualUnitPrice,BillDateKeyID,ProductKeyID
,Qty,Profit,DD.Date
, (SELECT TOP 1 ISNULL(S.Qty,0) FROM dbo.Stock S , dbo.DateDimension DD1
WHERE S.DateKeyID = DD1.DateKeyID AND
S.ProductKeyID = SF.ProductKeyID AND
DD1.Date <= DD.Date
ORDER BY DD1.Date DESC) as StockQty
, (SELECT ISNULL(SUM(Qty),0) from salesfact SF2,DATEDIMENSION DD2
WHERE SF2.BillDateKeyID=DD2.DatekeyID AND SF2.ProductKeyID=SF.ProductKeyid
AND DD2.Date > DD.Date
AND DD2.DATE=DD.Date
) as TotalQtySold
--INTO TEMP_Salesfact
FROM dbo.SalesFact SF INNER JOIN DATEDIMENSION DD
ON SF.billdatekeyid =DD.Datekeyid
WHERE
IsProfitCalculated = 1 AND
IsSalesFactSuppPopulated =0 AND
Qty > 0 -
How to use order by within Group by clause
Hi All,
I need a help as to how should i use the Order by clause so that the data should be in order with respect to one column, and at the same time whole data is grouped by some other column...like
Select RaceNo,Venue,FP,BP from Race group by RaceNo
Here I want to order by FP in ascending order for each group. When i am using it , whole order is changing.
Can anybody suggest me how to use order by clause that would apply to each group of data.
Thanks .order by clause should be used at the last in any query.......but in group by clause u can't use use that becoz u group according to column then no ordering is needed there......if u want to filter something then u can use having clause and later if u need to arrange then u can use order by clause.........
i hope this eg.l gives u some clarification....
e.g
select deptno,count(empno)
from dept
group by deptno
having count(empno) > 10
order by deptno -
Using order by in the select query
Hi All,
I have query in which I need the latest record. To get the latest record, I can
1) Select all entries into an internal table and sort them descending and get the first one
2) Select all entries into an internal table and order by in the select statement itself.
Then read the first one.
Which approach should be better as for as the performance is concern.
The query is on MKPF table and I have the material document number. I need the latest entry.
Regards,
ShahuHi,
The first one would be better.At the most we should not use order by in select statement bcoz it directly sorts the data according to that in database itself reverting performance issues.
Otherwise you can use select max* if records are less.
Reward points if helpful.
Thanks,
Ponraj.s. -
How to use order by in stored procedure base block?
How to use order by in stored procedure base block? I need to change order by dynamically
Use SET_BLOCK_PROPERTY('BLOCK_NAME',ORDER_BY,'COLUMN_NAME1, COLUMN_NAME2');
-
Issue in Batch import of Configuration orders using order Import
Hi All,
I am trying to import Configuration orders into Oracle R12 using Order import. As per Oracle white paper on this, I ahve populated all the required fields like top_model_line_ref,link_to_line_ref, item_type_code etc. But order import is giving error "Item ABC not found in BOM of Model XYZ".
Is there any setup or profile I am missing?
Please help me on this also is there any other approach to import Batch configuration orders?
Thanks!!you have to customize tha availability check on MM movements in OMCP
-
Using ORDER BY in UNION clause in cursor
Hi Everybody,
I have one situation and i need your help guys. I have to use ORDER BY in UNION of two queries and return value in cursor.
OPEN cursor FOR
SELECT ID, DESC,SID, ITID, SID_DESC
FROM (SELECT A.ID,
A.DESC,
B.SID,
NULL AS ITID,
B.SID_DESC
FROM TABLEA A, TABLEB B
WHERE A.ID = B.ID
order by A.SORTORDER asc,B.SORTORDER)
UNION
SELECT ID, DESC, ,SID,ITID, ITID_DESCRIPTION,
FROM (SELECT A.ID,
A.DESC,
NULL AS SID,
C.ITID,
C.ITID_DESC,
FROM TABLEA A,
TABLEC C
WHERE A.ID = C.ID
order by A.SORTORDER asc,C.SORTORDER)
I SORT ORDER is column in all three tables. TABLEA has unique number for each record as sort order. TABLEB has sortorder as 1 for each id. If id is two times then its 1 and 2 for each id. TABLEC has sort order as TABLEB, 1 for each id and if id is two times then it is 1 and 2 and id id is three times, it is 1, 2, 3.
I am not getting correct sorting as i cant use order by like this in UNION. Please let me know how i can handle this.
Thank you in advance to everybody.
I will really appreciate your comments and responses.Hi,
You can use ORDER BY in a sub-query, but there's usually no point in doing so, because the super-query won't necessarily preserve that order. You need to make the columns that you want to ORDER BY available to the main query, so that they can be used there.
Try this:
SELECT ID, DESC,SID, ITID, SID_DESC
FROM (
SELECT A1.ID,
A1.DESC,
B.SID,
NULL AS ITID,
B.SID_DESC,
A1.SORTORDER AS sortorder_1
B.SORTORDER AS sortorder_2
FROM TABLEA A1,
TABLEB B
WHERE A1.ID = B.ID
UNION
SELECT A2.ID,
A2.DESC,
NULL AS SID,
C.ITID,
C.ITID_DESC,
A2.SORTORDER AS sortorder_1
B.SORTORDER AS sortorder_2
FROM TABLEA A2,
TABLEC C
WHERE A2.ID = C.ID
order by SORTORDER_1 ASC -- ASC is the default, but it doesn't hurt to say it
SORTORDER_2This assumes that tableb.sortorder and tablec.sortorder have the same, or at least similar, data types. If not, explicitly convert sortorder_1 in one branch of the UNION to the type of sortorder_2 in the other branch.
Using the same alias to mean different things in the same query is just asking for trouble. I changed the table alias a (which was used in different places to mean two different things) to A1 and A2, each of which means only one thing.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using. -
Without using order by and connect by clause
hi all,
can i write a tree query without using start with clause and connect by clause
and
can i order the employee names in a select query without using order by clause
can those things are possible in select statement...dipuna wrote:
hi all,
can i write a tree query without using start with clause and connect by clause
and
can i order the employee names in a select query without using order by clause
can those things are possible in select statement...A very odd question.
Those clauses are the means to do what you are asking. Why would you be looking for some other method? -
How to use "Order by" clause dynamically on LOV values in 10g r2 forms
Hi ,
I have following requirement,please guide me.
1 Create a List Of Values with 2 fields, Code and Description
2. Do not use order by clause in record Group Query
3. Attach this LOV to a field in Form
4. When user invokes the LOV user will see two fields in LOV with header as Code and Description
5. Now when user clicks on Column Header “Code” then LOV should be sorted on Code
6. And if User clicks on Column Header “Description” then LOV should be sorted on Description
Thanks in Advance.Kindly post this problem in this forum ->
[Forms Forum|http://forums.oracle.com/forums/forum.jspa?forumID=82]
And, close this thread by marked it as answered. ;)
Regards.
Satyaki De. -
With out using order by clause
display the details of the employees with sal in descending order, without using order by clause
Don't forget that it's just for fun :)Well it's not entirely for fun :-)
There are real life users who might have real production problems and the rely and input/feedback from this forum.
I do not :)You spread untested answers/knowledge that might be wrong.
I can't imagine where you can see cartesian. It's
equijoin by primary key.I suggest you test it.
JFUI hierarchy is built after joining. And this
hierarchy is bamboo-tree. So result must be sorted
acording hierarchy.I know what hierarchical ordering is :-)
And here's a little test i did on your behalf, on the EMP table :-)
select e1.*
from e e1,
( select e2.id, count(*) as rn from e e2, e e3
where e3.sal >= e2.sal
and e3.id >= e2.id
group by e2.id
) e4
where e1.id = e4.id
start with e4.rn = 1
connect by e4.rn = prior e4.rn + 1
SQL*Plus: Release 10.1.0.4.2 - Production on Wed Jul 25 16:02:19 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name: scott/tiger
Connected to:
Oracle Database 10g Release 10.2.0.1.0 - Production
SCOTT@ORCL> set lines 1000
SCOTT@ORCL>
SCOTT@ORCL>
SCOTT@ORCL> select emp1.*
2 from emp emp1,
3 ( select emp2.empno, count(*) as rn from emp emp2, emp emp3
4 where emp3.sal >= emp2.sal
5 and emp3.empno >= emp2.empno
6 group by emp2.empno
7 ) emp4
8 where emp1.empno = emp4.empno
9 start with emp4.rn = 1
10 connect by emp4.rn = prior emp4.rn + 1;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7839 KING PRESIDENT 17-DEC-80 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7902 FORD ANALYST 7566 3000 20
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7934 MILLER CLERK 7782 1301 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7876 ADAMS CLERK 7788 12-JAN-83 1100 20
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7900 JAMES CLERK 7698 03-DEC-81 950 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
42 rows selected.
SCOTT@ORCL>Regards,
Tony -
Interesting Sort using ORDER BY
I would like to sort by footnote names in our table which should be sorted as below:
2a,2b,2c,3a,3b,3c,8,10,15,18
When I use ORDER BY FOOTNOTE_NAME, Oracle sorts the result like this:
10,15,18,2a,2b,2c,3a,3b,3c,8
which is not what I want.
Any ideas. Will I need to strip characters, convert the remaining part to Int and then sort. Does Oracle let you specify your own sort rules?
Thanks in advance.Assuming that the footnote names only have letters and numbers, then something like:
SQL> SELECT * FROM t;
COL
2a
2b
3b
3c
8
15
18
3a
2c
10
SQL> SELECT * FROM t
2 ORDER BY TO_CHAR(TRANSLATE(UPPER(col),'1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ',
3 '1234567890'),'0000')||
4 TRANSLATE(UPPER(col),'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890',
5 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
COL
2a
2b
2c
3a
3b
3c
8
10
15
18TTFN
John -
When prompted if I want to open or save a download, I choose SAVE and the usual window opens where I can choose a folder to save the download. After the last Firefox update, that SAVE window now displays all folders NOT in alphabetical order, but in Least Used to Most Recently Used order. Why??
Hi Brett555,
We wonder if there is any luck your issue has been resolved, if you've found solution by yourself. We would appreciate it if you could share with us and we will mark it as answer.
I am supposing you have this issue when you try to save files every time not just in office. Since It is possibly that this issue caused by certain software installation, as arnavsharma mentioned that please check your issue under safe mode.
If this issue persists, try creating a new user account and check if the issue persists there.
If it works in a new user account then you need to fix the corrupt user profile. You may visit this link for the steps:
http://windows.microsoft.com/en-US/Windows7/Fix-a-corrupted-user-profile
If this issue happened recently, please check any action you took or restore your system to earlier point.
Regards
D. Wu
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact [email protected] -
Help:Using Order by for a date column fetching wrong results
Hi all,
In my table I am having a date column which is having values
13/06/2007 09:24:00
31/05/2007 10:30:00
I am selecting this column with some other columns using order by at the end by giving the date column.
But I am getting rows in reverse order like above. I am using to_char(start_time,'dd/mm/yyyy hh:24mi:ss') in the select.
If I give to_date(start_time) in the order by the values are fetching correclty.But I was not allowed to use to_char in the select statement.
Kindly suggest me where it went wrong.
Thanks in advance.Hi , Thanks for the update. Actually that column was an Oracle DATE type. Earlier I gave simply that column name alone in the order by clause. That is getting falied only if the 2 entries falls in different months. Otherwise that is perfect.
So I gave to_date in the order by. But now I am facing a problem in the selecing that column. -
Services that can't use Order on Behalf
Services that can't use Order on Behalf
Hi - does anyone know if there is a way to exclude specific services from using Order on Behalf?Hi Wendy,
This use case can be handled by creating an AFC Conditional Rule that is triggered with the onLoad and onSubmit events. Please see below for the sample conditional rule:
Type:
Maybe you are looking for
-
Qty is automatically getting zero at the time of PGI from Deliveries in WM
When we go to PGI an order it changed all of the deliveries to zero and created an invoice at zero value. It is happening dramatically. it is not happening with every delivery. Thanks in advance
-
I want to edit an .png or .jpg image which has no mask and, once edited, that image could remain without mask. ¿Is it possible to do this with iPhoto and how? Thanks and regards.
-
NameSpace for XML But in SSIS Script Task
Hello, I am creating an xml Document that pulls information from a staging table in sql. However the issue I am having is that i need a namespace or a start element to handle a ':' but i keep getting its not a hexadecimal blah blah. I feel like I
-
CS6 desktop apps and Creative Cloud
Hi, This may be a dumb question [request!] but I bought the CS6 design and web premium [as disks] back in May. More recently, I signed up to Creative Cloud [free version] just to allow me to sync desktop apps with the just bought touch apps on my iPa
-
Forward a request from a filter
Hi, I want to be able to access a page www.whatever.com/page.jsp?username=me&content=something with the url www.whatever.com/user/something I am thinking doing it with a filter that parses out 'user' and 'something' in the second url and forward the