Error : The ORDER BY clause is invalid in views, inline functions, derived
Hi All,
I am on 11g 6.2, Windows Server 2008, my db SQL server 2008, I am facing the error for the reports in which I am trying to edit one the column formula and do something like 'abc/sum(abc)*100'.
10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.. [nQSError: 16001] ODBC error state: 37000 code: 1033 message: [Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000)
One of the solutions to this which I have found is to edit the EXPRESSION_IN_ORDERBY_SUPPORTED feature in the db properties.
I want to know what does EXPRESSION_IN_ORDERBY_SUPPORTED means?
When I create a calculations in 11g like abc/sum(abc) in the column formula for a column then i get this error.
What does this error mean? Does OBIEE 11g doesn't support using these expressions in the report and the fact that it applies the order by clause to the reports, the report fail?
Could anybody please explain the issue. There is very limited information on this over the web.
Thanks in advance.
Ronny
Thanks svee for the quick response, actually i had resolved the issue by unchecking the EXPRESSION_IN_ORDERBY_SUPPORTED option in the database. I want to understand how does that makes the difference?
What does EXPRESSION_IN_ORDERBY_SUPPORTED mean? Does it mean that if I give any expression in my answers report and since obiee uses a order by for all the queries, the expression won't be supported?
Please explain.
Similar Messages
-
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 16001] ODBC error state: 37000 code: 8180 message: [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.. [nQSError: 16001] ODBC error state: 37000 code: 1033 message: [Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.. [nQSError: 16002] Cannot obtain number of columns for the query result. (HY000)
I have already tried to follow this thread below, but no change.
HI
In this specific report ran above the offending sql uses a CTE.
I am on 11.1.1.6.1, Windows Server 2008
Currently in testing phase in migration from 10g.
I know what the error means, just not how to resolve it or what setting may be causing this.In Physical layer, go to specific database(Physical layer's) properties, database features tab -> Un check the EXPRESSION_IN_ORDERBY_SUPPORTED.
For that failed report, go to Answers-> advance tab-> Look for 'Advanced SQL Clauses'
Check this box to issue an explicit Select Distinct
Let me know updates
If helps Pls mark correct or helpful -
How to change the order by clause of a standard VO in OAF
Hi All,
I need to change only the order by clause of a standard VO (Which is attached to a messageChoice item).
Steps followed:
1)Created a custom VO by extending the standard VO .
2)VO Impl class files are not generated as seeded VO has no such class files.
3)Created a substitution
4)Imported it
5)When I try access the specific page, getting Sys Admin error without any clue about the error.
Even I tried to create the custom VO without extending the std VO ,
Still getting the same error .
Please provide your suggestions on this.
Thanks,
ThavamWhen I set the FND:Diagnostics profile option , I could see what was the exact error . It was SQL Wrapper exception error.
The VO which is extended , has a dynamic where clause with bind variables. The binding style of the extended VO does not match with seeded VO. It works when the binding style is changed.
Thanks,
Thavam -
Help Urgent! RowIterator retrieval doesn't respect the order by clause.
Hi,
Jdev 10.2.2
I'm using the RowIterator (source iterator) through a defined association to create rows in a destination RowIterator.
The creation of those rows must respect the order clause defined for the ViewObject => source Iterator.
I noticed that when I retrieve the rows through the RowIterator, the order clause is not respected?
Example of implementation:
Pre-defined weight levels for a postal tariff:
Product A:
From weight To weight
0 - 10
10 - 20
The user will have enter a price for each level.
I pre-create those rows so that only the price will have to be entered.
As you see the order of display/creation is important.
I there a way to make the RowIterator respect the Order Clause defined for the ViewObject?
I am a bit worried, please tell it's not the default behaviour!
Thanks
Frederic
For info my code:
RowIterator deliveryWeightIt = weightGroupImpl.getDeliveryWeightAssoc(); // source rows
if (deliveryWeightIt == null)
throw new JboException(getClass().getName()+".setWeightGroupId Detail row generation,. System error. DeliveryWeightAssoc is null.");
deliveryWeightIt.first();
Row currentDeliveryRow = deliveryWeightIt.getCurrentRow();
Row newPostalDetail = null;
try
while (currentDeliveryRow != null)
newPostalDetail = postalDetailIt.createRow();
SequenceImpl s = new SequenceImpl("SITE_POSTAL_REL_SEQ", getDBTransaction());
Number newSeq = s.getSequenceNumber();
System.out.println("numberOfGeneratedRows: "+numberOfGeneratedRows+", newSeq: "+newSeq+", FROMWEIGHT: "+currentDeliveryRow.getAttribute(DeliveryWeightImpl.FROMWEIGHT)); newPostalDetail.setAttribute(PostalDetailImpl.FROMWEIGHT,currentDeliveryRow.getAttribute(DeliveryWeightImpl.FROMWEIGHT));
newPostalDetail.setAttribute(PostalDetailImpl.TOWEIGHT,currentDeliveryRow.getAttribute(DeliveryWeightImpl.TOWEIGHT));
postalDetailIt.insertRow(newPostalDetail);
numberOfGeneratedRows++;
currentDeliveryRow = deliveryWeightIt.next();Ok I think I found my mystake.
I was using the entity association instead of using a view link.
I avoid using links because I encountered Class Cast exception => similar to thread 10.1.2: view Link accessors in entity object return ViewRow ??????
Will there be patch available soon?
Regards
Frederic -
The order doesn't work in my view with join between two lists. And now?
Hi,
I work with sharepoint 2010.
I did the join between two list follow this
post.
I did it and everything is ok, but the order doesn't work.
What can be it?
Thanks
K2rto'4 - Analista Sharepoint
"Hoje melhor do que ontem, amanhã melhor do que hoje!" 改 善Hi,
I've two lists in my view with join. The list A and the list B.
I'm ordering the view with the column list A.
The column list A it's a column for type lookup to list B's column.
In my view i'm ordering with the column list A of type lookup.
The view with join is not ordering in order growing.
I want the view will be ordering by order growing.
Do you understood?
Hugs
K2rto'4 - Analista Sharepoint
"Hoje melhor do que ontem, amanhã melhor do que hoje!" 改 善 -
Using ROWID in the ORDER BY clause
Hi,
I can consider myself as a PL/SQL beginner. I need to query some existing tables created for audit scope.
These tables have more duplicate rows respect to the same audit date: the precision is at "hour and minute and second" level.
But I need to understand which is the more recent row for the same audit date. So I think to use in the SELECT statement
the clause ORDER BY in this manner:
SELECT ... FROM Audit_Table ORDER BY Audit_Date desc, ROWID desc.
I'd like to use this ORDER BY also for the ROW_NUMBER function.
Any suggests to me about this topic? Many thanksI don't need to provide an example, I can do better by pointing you to the documentation:
http://docs.oracle.com/database/121/SQLRF/pseudocolumns008.htm#SQLRF00254
"If you delete a row, then Oracle may reassign its rowid to a new row inserted later" - for example
I can point you to asktom: https://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:912210644860
"ROWIDs are NOT sortable" - for example
Your example just happened to work, but you are using the rowid semantically incorrect. -
Which clause is overridden by the ORDER By clause
1. group by
2. having
3. select
4. where
5. fromIt implies that distinct, group by guarantees a
sorted order. I have seen Tom Kyte disprove this lots
of time....and 10.2 (in particular the hash group by) is going to screw up a lot of people who have mistakenly relied on this.
SQL> with t as (
2 select mod(rownum,10) as r
3 from user_objects
4 where rownum <= 100
5 )
6 select r
7 from t
8 group by r;
R
6
7
5
8
1
2
3
4
9
0
10 rows selected.
SQL> with t as (
2 select mod(rownum,10) as r
3 from user_objects
4 where rownum <= 100
5 )
6 select r
7 from t
8 group by r
9 order by r;
R
0
1
2
3
4
5
6
7
8
9
10 rows selected. -
This problem only happens with one website when I try to follow hyperlinks to other pages. They have directed me to Firefox troubleshooting section. I have followed the advice there but it has not solved my problem.
I haven't been able to go on line since 7.01 and up. I have to use ieexplorer. are you idiots or what. I can't even contact you because i have to be in your latest version but i can't get the internet with the latest version. good bye for good
-
I'd like to have my playlists sorted by Album by Artist/Year when exporting, but I can't figure out how to do it.
It should be:
Sort the playlist as Album by Artist\Year
Right-click on playlist name and click Copy to Play Order
Export playlist.
tt2 -
ORDER BY Clause in XMLAGG is throwing errors.
Hi,
I'm getting errors when generating the XML using the ORDER BY clause in the XMLAgg function. Although, running the SQL directly in SQL Plus doesn't have any problem.
Here is the PL/SQL sample.
DECLARE
vX_XML SYS.XMLTYPE;
vCL_XML CLOB;
BEGIN
SELECT XMLElement("GROUP",
XMLAttributes(Group_Id AS "ID", Group_Name AS "NAME", Group_Description AS "DESC"),
XMLAgg(XMLElement("FIELD",
XMLAttributes(Field_Id AS "ID", Field_Description AS "DESC",
Table_Name AS "TAB_NM", Rule_Name AS "RULE_NM",
Field_Hierarchy_Depth AS "DOL_VAR_CALC")) ORDER BY Field_Description))
INTO vX_XML
FROM (SELECT g.Group_Id, g.Group_Name, g.Group_Description, f.Field_Id, f.Field_Description,
DECODE(f.Table_Name, 'ESTIMATES', 'E', 'LINE_ITEMS', 'L', NULL) Table_Name,
rt.Rule_Name,
CASE NVL(f.Field_Hierarchy_Depth, 0) WHEN 0 THEN 'N' ELSE 'Y' END Field_Hierarchy_Depth
FROM GROUPS g,
Rules r,
Rule_Types rt,
Fields f
WHERE g.Group_Id = 3087
AND r.Group_Id_Fk = g.Group_Id
AND rt.Rule_Type_Id = r.Rule_Type_Id_Fk
AND f.Field_Id = r.Field_Id_Fk) tab
GROUP BY Group_Id, Group_Name, Group_Description;
vCL_XML := vX_XML.GetCLOBVal();
END;
And, here are the errors.
ERROR at line 8:
ORA-06550: line 8, column 23:
PLS-00306: wrong number or types of arguments in call to 'XMLAGG'
ORA-06550: line 8, column 23:
PL/SQL: ORA-00904: "XMLAGG": invalid identifier
ORA-06550: line 6, column 5:
PL/SQL: SQL Statement ignored
Thanks in Advance.
BTW, we are using Oracle 9.2.0.4.This is bug 2785463 with no ETA for a fix
regards
Coby D. Adams Jr. -
How to ORDER BY Different column than in the group by clause.
Hello, I have this sql statement
SELECT COUNT([Tags]) AS CNT, [Tags]
FROM [Tags], [Images]
WHERE
([Images].[Tags] LIKE '%' + [Tags].[LongTag] + '%') AND
([Tags].AllowTagPost = 'True' )
GROUP BY [Images].[Tags]
HAVING COUNT([Tags]) > 30
ORDER BY [Tags].[LastTagPost] DESC
It returns the tags, the number of occurances sorted by count. However, I want to sort it by a column in the Tags table named LastTagPost (DATETIME) The idea is to get the tag that hasn't been used in the longest time and also has more occurances
than 30 in the image table. When I try to order by this column i get an error that i'm sure most of you are all to familer with.
Error:
Column "Tags.LastTagPost" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
Any help would be greatly appreciated.Couldn't you just include the LastTagPost as a MIN?
DECLARE @tags TABLE (LastTagPost DATETIME, LongTag VARCHAR(100), allowTagPost CHAR(5))
DECLARE @images TABLE (tags VARCHAR(10))
SELECT COUNT(i.Tags) AS CNT, i.Tags, MIN(t.LastTagPost) AS lastTagPost
FROM @Tags t
INNER JOIN @Images i
ON i.Tags LIKE '%' + t.LongTag + '%'
WHERE t.AllowTagPost = 'True'
GROUP BY i.Tags
HAVING COUNT(i.Tags) > 30
ORDER BY LastTagPost DESC
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question. -
[JPA/TOPLINK] is the function "lower" supported in "order by" clause?
In EJB-QL
I can use lower() or upper() in where clause.
But there is always a parse exception thrown when i tried to use it in main clause or order by clause.
works:
select s from Student s where lower(s.name) like 'm%'
exception thrown:
select s from Student s where s.name like 'm%' order by lower(s.name)
OR --------------
Why i am asking this is that the resultset returned from database is not alphabetical sorted but ascii sorted, which means any characters with upper case is always prior to the ones with lower case.
If EJB-QL doesn't support using lower() in order by clause, do I have any other options to avoid this problem?
BTW, it is the Oracle 10g we are using as DB
many thanks,
Xuphey
Edited by: Xuphey on Nov 29, 2007 1:33 AMIf you want to do this, you'd have to use dynamic SQL (execute immediate or DBMS_SQL). For the easier 'execute immediate' approach, you'd do something like
create or replace someProc( someArg varchar2 )
as
strSQL varchar2(4000)
begin
strSQL := <<string containing your SQL statement up to the order by clause>>
strSQL := strSQL || 'ORDER BY ' || someArg
execute immediate strSQL;
endJustin -
What is the point in having multiple columns in ORDER BY clause?
DB version:10gR2
When using ORDER BY clause, the rows are always sorted according to the first column in the ORDER BY clause. So, what is point in having multiple columns in the ORDER BY clause(i always see this in production codes)?
For the below SQLs' from SCOTT schema, the result sets are always ordered according the first column ename. When i added job asc and job desc, the result set doesn't change.
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.Because there is only one employee with the name SCOTT,FORD ...etc in the emp table and your first column in the order by list is ename
you spot the difference now
SQL> select * from emp order by job;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 19-APR-87 00:00:00 3000 20
7902 FORD ANALYST 7566 03-DEC-81 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-82 00:00:00 1300 10
7900 JAMES CLERK 7698 03-DEC-81 00:00:00 950 30
7369 SMITH CLERK 7902 17-DEC-80 00:00:00 800 20
7876 ADAMS CLERK 7788 23-MAY-87 00:00:00 1100 20
7698 BLAKE MANAGER 7839 01-MAY-81 00:00:00 2850 30
7566 JONES MANAGER 7839 02-APR-81 00:00:00 2975 20
7782 CLARK MANAGER 7839 09-JUN-81 00:00:00 2450 10
7839 KING PRESIDENT 17-NOV-81 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 00:00:00 1500 0 30
7654 MARTIN SALESMAN 7698 28-SEP-81 00:00:00 1250 1400 30
7521 WARD SALESMAN 7698 22-FEB-81 00:00:00 1250 500 30
7499 ALLEN SALESMAN 7698 20-FEB-81 00:00:00 1600 300 30
14 rows selected.
Elapsed: 00:00:00.00
SQL> select * from emp order by job, deptno asc;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7902 FORD ANALYST 7566 03-DEC-81 00:00:00 3000 20
7788 SCOTT ANALYST 7566 19-APR-87 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-82 00:00:00 1300 10
7369 SMITH CLERK 7902 17-DEC-80 00:00:00 800 20
7876 ADAMS CLERK 7788 23-MAY-87 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-81 00:00:00 950 30
7782 CLARK MANAGER 7839 09-JUN-81 00:00:00 2450 10
7566 JONES MANAGER 7839 02-APR-81 00:00:00 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 00:00:00 2850 30
7839 KING PRESIDENT 17-NOV-81 00:00:00 5000 10
7654 MARTIN SALESMAN 7698 28-SEP-81 00:00:00 1250 1400 30
7844 TURNER SALESMAN 7698 08-SEP-81 00:00:00 1500 0 30
7521 WARD SALESMAN 7698 22-FEB-81 00:00:00 1250 500 30
7499 ALLEN SALESMAN 7698 20-FEB-81 00:00:00 1600 300 30
14 rows selected.
Elapsed: 00:00:00.01
SQL> select * from emp order by job,deptno desc;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7902 FORD ANALYST 7566 03-DEC-81 00:00:00 3000 20
7788 SCOTT ANALYST 7566 19-APR-87 00:00:00 3000 20
7900 JAMES CLERK 7698 03-DEC-81 00:00:00 950 30
7369 SMITH CLERK 7902 17-DEC-80 00:00:00 800 20
7876 ADAMS CLERK 7788 23-MAY-87 00:00:00 1100 20
7934 MILLER CLERK 7782 23-JAN-82 00:00:00 1300 10
7698 BLAKE MANAGER 7839 01-MAY-81 00:00:00 2850 30
7566 JONES MANAGER 7839 02-APR-81 00:00:00 2975 20
7782 CLARK MANAGER 7839 09-JUN-81 00:00:00 2450 10
7839 KING PRESIDENT 17-NOV-81 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 00:00:00 1500 0 30
7654 MARTIN SALESMAN 7698 28-SEP-81 00:00:00 1250 1400 30
7521 WARD SALESMAN 7698 22-FEB-81 00:00:00 1250 500 30
7499 ALLEN SALESMAN 7698 20-FEB-81 00:00:00 1600 300 30
14 rows selected.
Elapsed: 00:00:00.01
SQL> -
Bogus error message: "The field jnlp has an invalid value: https."
We are running into a variant of an old bug. With a Windows XP client using JRE 1.5.0_05, we get:
{noformat}Launch File Error: The field <jnlp> has an invalid value: https
Java 1.4+ is required for HTTPS support{noformat}
which of course is a strange thing for a 1.5 JRE to be squawking about. We found a Sun bug report 6433293 that reports this behavior as occuring on Solaris but not on Windows. We're seeing it on Windows. The bug report suggests that the error message text is the "wrong message" and may be totally unrelated to the actual problem (although it is triggered by having an https URL in the "href" attribute of the <jnlp> tag).
Because of our customer environment, upgrading the JRE beyond 1.5.0_05 is NOT an option for us. I googled the message and found one blogpost that suggested the error may be related to the XML encoding (which seems surprising, but they claimed changing the encoding fixed the problem for them). I tried fiddling with the encoding values, but to no avail. Anyone know anything about this bug, and any possible workarounds?We finally found the solution to this, so I will follow up for the sake of posterity. Thanks, Andrew, for the pointer to JaNeLa. While it didn't tip us off to this particular problem, it did get us thinking in the right direction: that there was something about the JNLP file, completely unrelated to what the error message was reporting, that was causing the problem. Turns out that the Java 1.5.0_05 WebStart JNLP parser had a bug, such that it was tripped up by a JNLP file containing more than one XML comment in immediate succession. It seems unbelievable, but it was completely reproducible. Our JNLP file began like this:
<?xml version="1.0" encoding="utf-8"?>
<!-- here's a valid XML comment -->
<!-- here's another valid XML comment, but it freaks out JWS 1.5.0_05 -->
<jnlp spec="1.0+" codebase="https://ourserver/ourApp" href="https://ourserver/ourApp/ourApp.jnlp"/> By accounts, this was patched in 1.5.0_10, and we know that the problem didn't occur in 1.6.0_13. In case anyone else has this problem, that's something to look for. (Note: this isn't the only cause of this erroneous error message. It apparently got printed out when the parser was unhappy about various things. I saw another report that someone had a problem with their "encoding" attribute value on their xml header, and fixing that solved their problem.) -
Why I cannot use RowID in where clause but can use it in order by clause
I am on SQL Server 2008.
1. If I use
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
order by RowID
Statement works
But
2. If I use
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
where RowID > 10000
I get error, RowID is an invalid column Name why? How to correct query 2.This is due to the logical evaluation order of a SELECT statement. Logically, a SELECT statement is computed in the order:
FROM (which includes JOIN)
WHERE
GROUP BY
HAVING
SELECT
ORDER BY
OFFSET
Thus, you can use what is defined in the SELECT list in the ORDER BY clause, but not in the WHERE clause.
In the case of row_number(), this has immediate repurcussions. row_number() is computed from the rows as they arrive the SELECT clause, and if you then you would filter on the value in the WHERE clause you would be going round in circles.
To do what you are looking for, you use a nested table, for instance with a CTE:
WITH numbering AS (
SELECT (ROW_NUMBER() over
(order by ImportId, ScenarioId, SiteID, AssetID, LocalSKUID, WEEKID, MonthID)) RowID, *
FROM [JnJ_Version1].[dbo].[td_Production_Week]
SELECT *
FROM numbering
WHERE RowID > 10000
Erland Sommarskog, SQL Server MVP, [email protected]
Maybe you are looking for
-
Not able to Start the oracle db error "ORA-01031: insufficient privileges"
Hi experts, I have oracle 11g setup on so solaris. i changed the db_cache_size & processes values and stopped the DB services after that i am not able to start the oracle DB. Listener is running. when i start the db server its giving the below error(
-
Hi all, I am using Developer v. 6i for a long time. No I need to convert all files to 10g developer suite. How can I convert It. 10g Developer suite should install all client site also .. or it is web type application... all file to keep in server ma
-
Cats webdynpro - Null Pointer Exception
Hi all, I am running cats webdynpro application (ess~cat/CatDataRecord) using the portal testid and getting the below dump: java.lang.NullPointerException at com.sap.xss.hr.cat.record.vac.calendar.VcCatCalendarView.wdDoModifyView(VcCatCalendarVie
-
Workflow Integration with OID - wfdircsv.sql query
Hi all, According to Workflow Guide Release 2.6.2 & metalink note 207225.1, when setting up OID integration you need to run the wfdircsv.sql script. This script sets the mappings of directory service views only to the WF_LOCAL tables. However, becaus
-
Not a valid Win32 application error when starting javahost
Hi, I am getting the error below. I have searched this forum and the web and found some mentions of it here and there, but no solutions (by the way I am not using MS IIS). OBI EE is installed on Windows Server 2003 Standard x64 Edition with Service P