WITH the ORDER BY clause and bug SDO_GEOMETRY?
I'm having a problem using SDO_GEOMETRY in a WITH clause. Specifically with ORDER BY. I'll show a shortened version of SQL here. I'm doing something wrong or is this a bug?It works:
SELECT
loc.location_id,
SDO_GEOM.SDO_DISTANCE(cent.lat_long,
MDSYS.SDO_GEOMETRY
(
2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
'4326',
SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
NULL,
NULL
),
0.01, -- tolerance
'unit=mile') result_center_distance
FROM location loc
JOIN centroid cent ON loc.centroid_id = cent.centroid_id
ORDER BY result_center_distance
After the statement select in a with clause, this does not work, which gives an identifier not valid "SDO_GEOMETRY" ORA-00904:WITH location_distance AS
(
SELECT
loc.location_id,
SDO_GEOM.SDO_DISTANCE(cent.lat_long,
MDSYS.SDO_GEOMETRY
(
2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
'4326',
SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
NULL,
NULL
),
0.01, -- tolerance
'unit=mile') result_center_distance
FROM location loc
JOIN centroid cent ON loc.centroid_id = cent.centroid_id
ORDER BY result_center_distance
) SELECT * from location_distance
If I duplicate the function of the distance in the ORDER BY, it works:WITH location_distance AS
(
SELECT
loc.location_id,
SDO_GEOM.SDO_DISTANCE(cent.lat_long,
MDSYS.SDO_GEOMETRY
(
2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
'4326',
SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
NULL,
NULL
),
0.01, -- tolerance
'unit=mile') result_center_distance
FROM location loc
JOIN centroid cent ON loc.centroid_id = cent.centroid_id
ORDER BY SDO_GEOM.SDO_DISTANCE(cent.lat_long,
MDSYS.SDO_GEOMETRY
(
2001, -- SDO_GTYPE attribute: 2 in 2001 specifies dimensionality is 2.
'4326',
SDO_POINT_TYPE(-78.6386145, 35.772096, NULL),
NULL,
NULL
),
0.01, -- tolerance
'unit=mile')
) SELECT * from location_distance
This is a bug. But it is set to 11g R2. Note that this is not a space bug, but a bug in generic compilation.
Tags: Database
Similar Questions
-
Purpose of the ORDER BY clause in the analytic function Min Max
I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.user10566312 wrote:
I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.It is a good point that many developers are not so aware. As far as I understand it the way it works.
Some analytical functions do not need an order by or windowing clause (SUM, COUNT, MIN, etc.). If there is no specified window, then the full score is the window.
As soon as you add a command also add you a windowing clause. This window has the default value of 'rank ofrowsbetween unbounded preceding and current_row. So as soon as you add an order by clause, you get a sliding window.Documentation: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
windowing_clause
...
You cannot specify this clause unless you specified the order_by_clause. Window limits defined by the clause RANGE you can not specify only a single expression to the > order_by_clause. Please refer to 'Restrictions on the ORDER BY Clause'.example of
with testdata as (select 10 numval, level lv from dual connect by level < 10) select lv, numval, sum(numval) over () sum1, sum(numval) over (order by lv) sum2 from testdata; LV NUMVAL SUM1 SUM2 -- ------ ---- ---- 1 10 90 10 2 10 90 20 3 10 90 30 4 10 90 40 5 10 90 50 6 10 90 60 7 10 90 70 8 10 90 80 9 10 90 90
Published by: Sven w. on 25 Sep 2012 16:57 - default behavior has been corrected. Thanks to Chris
-
order by clause and index access
Hi all
I have tried under request.
SELECT e.employee_id, e.department_id
E EMPLOYEES
order by 2;
Implementation plan...
SELECT STATEMENT, GOAL = ALL_ROWS 4 107 856
SORT ORDER BY 4 107 856
TABLE ACCESS FULL EMPLOYEES OF HR 3 107 856
Below query Oracle by using the INDEX FULL SCAN. I'm not able to find an appropriate explanation. Pls how me oracle optimizer include order by clause while to fetch documents.
-departmentId has index EMP_DEPARTMENT_IX, which is the normal index.
SELECT e.employee_id, e.department_id
E EMPLOYEES
order by 1;
SELECT STATEMENT, GOAL = ALL_ROWS 3 107 856
TABLE ACCESS BY INDEX ROWID HR 3 107 856
INDEX FULL SCAN HR EMP_EMP_ID_PK 1 107
Thank you.Consolidation of the index factor is used by the CBO to calculate how much is a scan interval index (the one that is followed by a table-access by rowid) for this index will be. The CBO calculates this option to select an index if two or more paths index are available.
But it could also be used to decide between choosing a full index scan (to honor an order by clause and without having to sort after the scan) in the course of a full table scan that requires an extra sort (in honor of the order by clause) operation.There are many articles talking about this:
http://www.oaktable.NET/category/tags/clustering-factor
http://Oracle-Randolf.blogspot.com/2010/01/clusteringfactor-what-if-analysis.html
http://mehrajdba.WordPress.com/2009/02/09/index-clustering-factor/
I just realized today that in case you described: If department_id column is NULL-able, Oracle cannot use the index in department_id to honor the order by clause, because he would find all the lines (those with an id of NULL service), in this case.
-
passing parameters in the order by clause of the cursor
Hi friends,
I am facing a strange problem
I have a cursor with an order by clause.
OPEN FOR Cursor_nomrpt
SELECT DISTINCT
CAST (plano.desc3 AS VARCHAR2 (50)) category
plano.name plan_name
, chip nvl (CAST (plano.desc6 AS VARCHAR2 (50)), 'not applicable')
, nvl (trunc(plano.value18,2), 0) nominal_slm
, nvl (trunc(plano.value19,2), 0) blm
plano.dbdateeffectivefrom date_live
,
Plano.DBKEY pog_id
, case when plano.value47 < 0 THEN 0 when plano.value47 IS NULL THEN 0 ELSE plano.value47 END as parent_id
Of
Plano dplapro1.ix_spc_planogram
INNER JOIN dplapro1.ix_spc_performance ON plano.dbkey = perf.dbparentplanogramkey perf
Produces INNER JOIN dplapro1.ix_spc_product ON perf.dbparentproductkey = product.dbkey
INNER JOIN dplapro1.ix_spc_product_key ON product.dbkey2 = prodkey.dbkey prodkey
AND prodkey.keylevel = 2
WHERE
Plano.value50 = 0
AND plano.dbkey4 = p_subcatkey
ORDER BY ltrim (rtrim (p_orderby)) CSA;
p_orderby is the parameter that is passed. But the result is not sorted. But when I run the cursor to hardcode the value of parameter, that it works fine...
Need your help on thisHello
When you use a local variable in a cursor, it's as if you had hard-coded literal in its place, you cannot use a variable to a column name.
If you know all the possible values for p_orderby, you can do something like this:
... ORDER BY TRIM ( CASE p_orderby WHEN 'DESC' THEN plano.desc WHEN 'VALUE' THEN plano.value ... END ) ASC;
If you don't know not all possible values, you can use dynamic SQL statements.
By the way
TRIM (x)
Returns the same results as
LTRIM ( RTRIM (x))
-
How to remove the Order By clause
How can I get rid of the Order By clause in the underlying SQL query? I created a simple hierarchy, but when I use the hierarchy in the analysis and then come down, the results show multiple occurrences of each child. For some reason, I was able to reduce the number of occurrences of each child by adding a saved filter.
I was expecting this:
Instead, I got this:
The generated physical query looks like this:
SET VARIABLE QUERY_SRC_CD = "report"; SELECT s_0, s_1, s_2, s_3, s_4 s_5, (FROM s_6)
SELECT
s_0 0,.
CAST (NULL AS VARCHAR s_1 (1)).
"Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.
'All the colleges' s_3,.
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").
MOUNT s_5 (NULL AS DOUBLE),
"Registration - College". "" Counties of schooling. "" Full-time student "s_6
"REGISTRATION - College".
UNION ALL
SELECT
1 s_0
"Registration - College". «Dimensions of the inscription '.» "" Name of College "s_1,.
"Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.
'All the colleges' s_3,.
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_5 College ').
"Registration - College". "" Counties of schooling. "" Full-time student "s_6
"REGISTRATION - College".
WHERE
("Registration - College". «Dimensions of the inscription '.» ("' Exercise ' IN ('201213')) AND (IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". (("' Colleges ') (1))
) djm ORDER OF 1, 3 ASC NULLS LAST, 4 ASC NULLS FIRST, 5 ASC NULLS FIRST, 2 ASC NULLS FIRST, NULLS FIRST CSA 6
EXTRACT FIRST 10000000 LINES ONLY
HI mbengue,.
Check the report you are running any column presentation sorted in the user interface (in which case the order by clause will creep into generated sqls Physics). Also, I think that its worth it to check the settings of the hierarchy you have configured and if the installation program for the calculation of the measured column (number of students in this case), has been done correctly.
Kind regards
Arko
-
What's the point of having several columns in the ORDER BY clause?
DB version: 10 gr 2
When you use the ORDER BY clause, the lines are always sorted by the first column in the ORDER BY clause. So, what's the point of having several columns in the ORDER BY clause (I always see this in production codes)?
For the below SQLs' schema SCOTT, result sets are always classified according to the first column ename. When I added use asc and desc of employment, does not change the result set.
SQL> select * from emp order by ename; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected. SQL> select * from emp order by ename, job desc; EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO ---------- ---------- --------- ---------- --------- ---------- ---------- ---------- 7876 ADAMS CLERK 7788 23-MAY-87 1100 20 7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30 7698 BLAKE MANAGER 7839 01-MAY-81 2850 30 7782 CLARK MANAGER 7839 09-JUN-81 2450 20 7902 FORD ANALYST 7566 03-DEC-81 3000 20 7900 JAMES CLERK 7698 03-DEC-81 950 30 7566 JONES MANAGER 7839 02-APR-81 2975 20 7839 KING PRESIDENT 17-NOV-81 5000 20 7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30 7934 MILLER CLERK 7782 23-JAN-82 1300 20 7788 SCOTT ANALYST 7566 19-APR-87 3000 20 7369 SMITH CLERK 7902 17-DEC-80 800 20 7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30 7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30 14 rows selected.
Search in this example, you will see the difference
SQL> create table test_order (name varchar2(10), surname varchar2(10), age number); Table created. SQL> insert into test_order values('Kamran','Agayev',26); 1 row created. SQL> insert into test_order values('Kamran','Taghiyev',26); 1 row created. SQL> insert into test_order values('John','Kevin',23); 1 row created. SQL> select * from test_order; NAME SURNAME AGE ---------- ---------- ---------- Kamran Agayev 26 Kamran Taghiyev 26 John Kevin 23 SQL> select * from test_order 2 order by age; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Agayev 26 Kamran Taghiyev 26 SQL> select * from test_order 2 order by age asc, surname desc; NAME SURNAME AGE ---------- ---------- ---------- John Kevin 23 Kamran Taghiyev 26 Kamran Agayev 26 SQL>
When in the second query, I sorted out only for age, you saw it there two 26 years old Keita, there was first Agayev, then Taghiyev. But if I want to get the family names in descending order when there are two very old person, then I will add the second column in the order by clause
- - - - - - - - - - - - - - - - - - - - -
Kamran Agayev a. (10g OCP)
http://kamranagayev.WordPress.com -
I have a system dual-bootable Windows Vista SP2 and Firefox updated to 28 on both systems. Since the update of the tabs more reopen empty with the label "New tab" and "topic: vacuum" in the address line of Firefox is restarted. The tabs that open correctly seem to be those who in fact, I was at the session of prefious. I can recover the missing tabs using the Session Manager to pick up a previous session, but of course it does not pick up the tabs open in future sessions. It seems that the tabs that I go to the session recovered are saved correctly, as indicated above, but which are not revisited in the context of the use of the session retrieved will drop the URL next time that I open Firefox it again.
jdgale:
I don't have the time to do it. However, 29 is just around the corner and we will put in the channel of exit 29, then hope that the issue is not you.
P.S. I had originally chosen your last answer as the solution that you have migrated more to 29 but it seems that you have taken off. I'll be marking your last answer as the solution so that we can get out of the queue.
-
Firefox is compatible with the window Surface Pro and Win Phone 8
Firefox is compatible with the window Surface Pro and Win Phone 8
A user has posted here the other day that uses a Surface Pro 2 with Windows 8.1, then it should work basically the way it works on a desktop or laptop computer.
Windows Phone, I don't think.
-
Don t work under El Capitan and I don't get an update/upgrade? I've used until yesterday an old MacBook pro and Lion, everything was perfect with an opening. Now, with the new element (iMac) and El Capitan, I have problems.
It is not possible to update the version of Aperture is 3.4.5
What can I do?
You can only update if you have a version of the AppStore of Aperture - if your version of Aperture appears in the history of your purchases on the App Store. Update and then reinstalling. See this tip of the user for more details:
-
Missing once more, the blue band at the top of my Web page that has the file ',' Edit etc and the toolbar with the House for 'Home' and the arrow «back to last page»
== My grandchildren's play about that.
Press the Alt key to display the Menu bar, then open view > toolbars and select menu bar and the bar of Navigation, so that they have a check mark.
-
I want to buy an iBook. There are 2 different books with the same name, author, and the book cover. They are different number of pages with different prices. Specifically, all the light that we do not see. " How do you know that we purchase?
I would get one that has 4700 comments already.
-
Text messages sent with an email address from a touch ipod duplicated on a second ipod touch using a different email address, but the two ipods are controlled by a parent with the same apple ID and password. This has happened recently. My two girls have used their respective ipods and texting, without their messages of duplication for each of the other ipods for more than a year. Somehow recently, both addresses seem to be synced with them or something, so that both see each and other messages. I've recently updated two ipods, iTunes on my computer--not the cloud and added music for two ipods, but has not changed anything by email email settings or message I know. Help, please!
Welcome to the Apple community.
I can't fully follow how you have everything set up, but a glance at the settings > messages > send & receive
-
I have a second hand iPhone and cannot configure as the person he was find my iPhone on the phone and wont let me sign in with my Apple or the password and IE to communicate with the person he was and connect you with there Apple ID and then cut to find my iphone. Unfortunately o cannot get in contact with that I had to and now can't activate my phone can anyone help? Is there another way I can get into my new phone
There is no possible way to turn it off without having to contact the original owner. Nothing whatsoever.
This is why you should always check if find my iPhone is not activated on a used phone.
-
HP7520: How to scan 2 pages with the automatic document feeder and save to a file?
How can I scan 2 pages with the automatic document feeder and save to a file? (Right now, it happens that 2 separate files)
I have a HP7520, & again, I wish scan 2 pages into a single jpeg file.
Thank you
Well, in general JPEG format does not support several concept as a document page. Thus, each image in the JPEG file is saved in a single file. If you are considering of reduction of 2 images in 1 paper size (example: A4), you may need some image editor to do
If you are looking for a mulit-page image format, TIFF can be a format suitable to use.
-
How to stop a Web site generating spams are sent to me - it is all associated with the use of viagra and I had 10 different emails today
Thank you
You need to ask the experts of Hotmail one.Help for Windows Live Hotmail can be found in this forum.
http://answers.Microsoft.com/en-us/windowslive/Forum/Hotmail?tab=all
Help for Outlook.com is located in this forum
http://answers.Microsoft.com/en-us/windowslive/Forum/mail?tab=all
Maybe you are looking for
-
Can ' t install iTunes on a Windows PC running Windows 10 pro 64-bit
I tried several times to install iTunes without success. I tried uninstalling and reinstalling without success. The main error seems to be the 2 error, but I get another error that is great to include the part passing through the installation process
-
I run Windows 7 64 bit. I was about to install a new machine and, in the process, done something to cause Firefox to not display much of the formatting in the pages I visit. The missing information includes background color and contours and colors, t
-
Satellite M30-241, unable to boot
Hello! I had a Satellite SM30-241, age of 5 years. The problem is that I can't start for three days. Last week, he started with the advice that there is not enough RAM, but it has 1.2 GB of RAM and this has never been a problem. So sometimes the moni
-
Satellite L500-1ZP - key to enter the BIOS version 2.10 and the upgrade of RAM
Hello I have two questions: 1. I recently updated my bios version of laptops to 2.10 and replaced the hard drive with an SSD.However, it seems that I can't enter the BIOS more. I tried several buttons, but it just won't let me get bios of the laptop
-
UIMessage customized by the treatment model using batch
Hello I have some difficulties, try to use the UIMessages in batchmodel, but first let me explain my situation: I use a PXI to test 6 DUT, knowing this, I wanto to use the model batch in teststand and send data to the User Interface customized using