In Oracle SQL, cannot use column in select statement and order by
Hi,
Is there a work around for this.
Thanks in advance
Pablo.
Hi,
943981 wrote:
Hi All,
This is the error I get:
ORA-00960: ambiguous column naming in select list
00960. 00000 - "ambiguous column naming in select list"
*Cause: A column name in the order-by list matches more than one select
list columns.
*Action: Remove duplicate column naming in select list.
Error at Line: 6 Column: 17That error message looks pretty clear to me. What don't you understand?
Either
(a) use aliases, so each column has a unique name, or
(b) remove duplicate columns from the SELECT clause.
Post your query. It's hard to say exactly what you're doing wrong when we don't know exactly what you're doing.
For best results, post a complete test script (including CREATE TABLE and INSERT statements, if necessary) that people can to re-create the problem and test their ideas.
See the forum FAQ {message:id=9360002}
Similar Messages
-
PL/SQL: ORA-22992: cannot use LOB locators selected from remote tables
Dear ALL,
My O/S is Redhatlinux 5.2 and i had Migrated my Oracle databse to 11g2. But after that while i am retrieving records through dblinks from one of my other Oracle 9.2.0.8 databse it's throwing the error : PL/SQL: ORA-22992: cannot use LOB locators selected from remote tables.* This error i am getting in TOAD as well as SQL Developer.
Can anybody tell me how to fix this error ? Because am not able to get the records.
Also am getting another error during retrieving data from some of my tables after migrating i.e the table which having CLOB data type while am accessing to retrieve the records using select query it's throwing the error :
+(The following error has occurred:+
A query with LOB's requires OCI8 mode, but OCI7 mode is used.)
If anyone having any idea kindly share.
Thanks and Regards
BiswaHi,
Ya what u sent that is fine. But already am using one procudure which is accessing LOB data from another databse through DBlink and working fine. But there Both the databse are 9.2.0.8.
But while am executing the same procedure in oracle 11g where the Dblink accessing the data from Oracle 9i , there am getting this error.
Kindly tell if u know any resolution.
Thanks -
Bind Variable in SELECT statement and get the value in PL/SQL block
Hi All,
I would like pass bind variable in SELECT statement and get the value of the column in Dynamic SQL
Please seee below
I want to get the below value
Expected result:
select distinct empno ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
100, HR
select distinct ename ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
TEST, HR
select distinct loc ,pr.dept from emp pr, dept ps where ps.dept like '%IT' and pr.empno =100
NYC, HR
Using the below block I am getting column names only not the value of the column. I need to pass that value(TEST,NYC..) into l_col_val variable
Please suggest
----- TABLE LIST
CREATE TABLE EMP(
EMPNO NUMBER,
ENAME VARCHAR2(255),
DEPT VARCHAR2(255),
LOC VARCHAR2(255)
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (100,'TEST','HR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (200,'TEST1','IT','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (300,'TEST2','MR','NYC');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (400,'TEST3','HR','DTR');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (500,'TEST4','HR','DAL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (600,'TEST5','IT','ATL');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (700,'TEST6','IT','BOS');
INSERT INTO EMP (EMPNO,ENAME,DEPT,LOC) VALUES (800,'TEST7','HR','NYC');
COMMIT;
CREATE TABLE COLUMNAMES(
COLUMNAME VARCHAR2(255)
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('EMPNO');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('ENAME');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('DEPT');
INSERT INTO COLUMNAMES(COLUMNAME) VALUES ('LOC');
COMMIT;
CREATE TABLE DEPT(
DEPT VARCHAR2(255),
DNAME VARCHAR2(255)
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('HR','HUMAN RESOURCE');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('MR','MARKETING');
INSERT INTO DEPT(DEPT,DNAME) VALUES ('IT','INFORMATION TECH');
COMMIT;
PL/SQL BLOCK
DECLARE
TYPE EMPCurTyp IS REF CURSOR;
v_EMP_cursor EMPCurTyp;
l_col_val EMP.ENAME%type;
l_ENAME_val EMP.ENAME%type;
l_col_ddl varchar2(4000);
l_col_name varchar2(60);
l_tab_name varchar2(60);
l_empno number ;
b_l_col_name VARCHAR2(255);
b_l_empno NUMBER;
begin
for rec00 in (
select EMPNO aa from EMP
loop
l_empno := rec00.aa;
for rec in (select COLUMNAME as column_name from columnames
loop
l_col_name := rec.column_name;
begin
l_col_val :=null;
l_col_ddl := 'select distinct :b_l_col_name ,pr.dept ' ||' from emp pr, dept ps where ps.dept like ''%IT'' '||' and pr.empno =:b_l_empno';
dbms_output.put_line('DDL ...'||l_col_ddl);
OPEN v_EMP_cursor FOR l_col_ddl USING l_col_name, l_empno;
LOOP
l_col_val :=null;
FETCH v_EMP_cursor INTO l_col_val,l_ename_val;
EXIT WHEN v_EMP_cursor%NOTFOUND;
dbms_output.put_line('l_col_name='||l_col_name ||' empno ='||l_empno);
END LOOP;
CLOSE v_EMP_cursor;
END;
END LOOP;
END LOOP;
END;user1758353 wrote:
Thanks Billy, Would you be able to suggest any other faster method to load the data into table. Thanks,
As Mark responded - it all depends on the actual data to load, structure and source/origin. On my busiest database, I am loading on average 30,000 rows every second from data in external files.
However, the data structures are just that - structured. Logical.
Having a data structure with 100's of fields (columns in a SQL table), raise all kinds of questions about how sane that structure is, and what impact it will have on a physical data model implementation.
There is a gross misunderstanding by many when it comes to performance and scalability. The prime factor that determines performance is not how well you code, what tools/language you use, the h/w your c ode runs on, or anything like that. The prime factor that determines perform is the design of the data model - as it determines the complexity/ease to use the data model, and the amount of I/O (the slowest of all db operations) needed to effectively use the data model. -
Execute an sql command other than an select statement
hello,
is it possible to execute an sql-command other than a
select statement in a report ?
something like execute ... ?
i want ro execute a statement BEFORE the select ...
or is the one and only possible statement in a report
a "select ?"
greetings
Thorsten LorenzHi ,
You can always use the Report triggers to execute any other SQL commands . If you need to execute them before the SELECT statement of you Data Model query , then You can use the Parameter Form triggers / before Report Trigger. Be sure to put in a commit statement as well, if the result of the Select statement you intend to do depends on these SQL commands.
Thanks
Oracle Reports Team. -
Using procedure in SELECT statement
I have a select statement that currently uses 4 functions to receive necessary values. All the functions are recursive and returns values from the same row.
What I would like to do is replace these for function calls with 1 procedure. Does anybody know if it possible to use a procedure in this way inside a select statement?
If so, do you have the syntax for doing this?
E.g
SELECT
Mdbrd_Pkg.calculate_fixed_charge_fn(in_rc_id, ap.CONFIGSET_ID) AS FIXED_CHARGE,
Mdbrd_Pkg.calculate_charge_rate_fn(in_rc_id, ap.CONFIGSET_ID) AS CHARGE_RATE,
Mdbrd_Pkg.tax_liable_fn(in_rc_id, ap.CONFIGSET_ID) AS TAX_LIABLE,
Mdbrd_Pkg.charge_unit_fn( in_rc_id, ap.CONFIGSET_ID) AS CHARGEUNIT_ID
FROM .....This cannot be done. The part of the function used in the SELECT statement is the return value: procedures don't have return values (that's what makes tham procedures and not functions).
Obviously I don't know what your code does, but you should consider putting them into a single function that returns a TYPE with four attributes and then using the TABLE() function to cast them into something you could reference in the FROM clause of a correlated sub-query. Sounds a bit messy though.
Do these functions actually select data? Where does the recursion fit in?
Cheers, APC -
In oracle rac, If user query a select query and in processing data is fetched but in the duration of fetching the particular node is evicted then how failover to another node internally?
The query is re-issued as a flashback query and the client process can continue to fetch from the cursor. This is described in the Net Services Administrators Guide, the section on Transparent Application Failover.
-
Why I Can't use procedure in select statement
Why I Can't use procedure in select statement
We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
Regards,
Avinash -
I am using background pictures and want to cut out objects from other jpegs using the quick select tool and drop them into the background picture. So if i have a banana and select the object i need to copy the banana into the other background.
Hope this makes sense.
GarySelect banana. Right click>layer via copy. Move tool. Click and drag to other file. Drop on image.
OR: load the background and banana in one stack (File>Scripts>Load File Into Stack). Select banana and layer via copy or create layer mask.
Benjamin -
my question is will it possible to use oracle sql commands in toad and genterate the reprot like I have below.
my second question is can I embede this oralc sql command in my apps. to have the out put I have below. I tried and got an error message. I am wondering if this is possible
SQL> -- Multiple COMPUTEs are also allowable.
SQL>
SQL> SET echo off
SQL> BREAK ON city skip1 ON start_date
SQL> COMPUTE sum max min of salary ON city
SQL> COMPUTE sum of salary ON start_date
SQL> SET verify off
SQL> SELECT id, first_name, salary, city FROM employee ORDER BY city
2 /
ID FIRST_NAME SALARY CITY
07 David 7897.78 New York
06 Linda 4322.78
4322.78 minimum
7897.78 maximum
12220.56 sum
01 Jason 1234.56 Toronto
1234.56 minimum
1234.56 maximum
1234.56 sum
05 Robert 2334.78 Vancouver
08 James 1232.78
03 James 6544.78
02 Alison 6661.78
04 Celia 2344.78
1232.78 minimum
6661.78 maximum
19118.9 sumHi,
All of theose SQL*Plus features can be duplicated in Oracle SQL. For example, "GROUP BY ... ROLLUP" can give you an minimum, maximum and total for each city.
You can create a view that looks exactly like the SQL*Plus output (for example, the city column with values like 'New York', NULL, '**********', and 'minimum'), if you really need to. CASE is very useful for things like this, as are some analytic functions. (E.g., ROW_NUMBER can help in telling which is the first row for each city.)
To make such a view, you may find it convenient to do a UNION of two queries:
(1) One that produces one row per employee
(2) One that produces a fixed number of rows (four, to get the results you posted) per city -
Create a RowCounter as cannot use rownumber as select has orderby
Say I have a select statement
Select employee_no,salary,dept
order by salary
which would give the result
Employee_no Salary dept
2045 1000 G
3067 2000 A
1089 3000 P
i want a counter in the next column to read 1,2,3 i.e
Employee_no Salary dept CNTR
2045 1000 G 1
3067 2000 A 2
1089 3000 P 3
I cannot use rownum beacuse once you use orderby the rownums are all mixed up
any ideas anyone
thanks in advance
Cheers
ChrisEither
Select employee_no,salary,dept, row_number() over (order by salary)
from some_table
order by salaryor
select a.*, rownum
from (Select employee_no,salary,dept
from some_table
order by salary) ashould work. I would prefer the former, but if you are using a particularly old version of Oracle, you may not have analytic functions.
Justin -
Using functions in select statement(joining 5 tables) taking long time in Oracle
Hi,
I have created a query in oracle which joins 5 tables and uses two functions(function names are 'ca_concat' and 'ca_concat_noseq').
Query takes approximately 40 secs to execute around 12000 records. If I remove the functions from query it excutes within a second..
Note : I have used the oracle SQL Developer for testing the query.
It would be appriciated if anybody helps me to improve the perfomance of the query.
Below are the querie with and without functions:
1. Query with functions:
select
imsAuditEvent12.id as ID,
imsAuditEvent12.audit_time as AUDIT_TIME,
imsAuditEvent12.admin_dn as ADMIN_DN,
imsAuditEvent12.admin_name as ADMIN_NAME,
imsAuditEvent12.event_name as EVENT_NAME,
imsAuditEvent12.event_description as EVENT_DESCRIPTION,
imsAuditEvent12.event_state as EVENT_STATE,
imsAuditEvent12.envname as ENVNAME,
imsAuditTaskSession12.task_name as TASK_NAME,
imsAuditTaskSession12.id as TASK_ID,
imsAuditTaskSession12.task_description as TASK_DESCRIPTION,
imsAuditTaskSession12.task_priority as TASK_PRIORITY,
S1.OBJECT_ID,
S1.OBJECT_NAME as OBJECT_NAME,
S1.OBJECT_TYPE as OBJECT_TYPE,
S2.ATTRIBUTE_NAME as ATTRIBUTE_NAME,
S2.ATTRIBUTE_OLDVALUES as ATTRIBUTE_OLDVALUES,
S2.ATTRIBUTE_NEWVALUES as ATTRIBUTE_NEWVALUES,
S3.OBJECT_DN as OBJECT_DN,
S3.OBJECT_TYPE as IMSOBJECT_TYPE,
S3.CONTAINER_NAME as CONTAINER_NAME,
S3.CONTAINER_DN as CONTAINER_DN,
S3.CONTAINER_TYPE as CONTAINER_TYPE
from
imsAuditEvent12 LEFT JOIN imsAuditTaskSession12 ON imsAuditTaskSession12.id=imsAuditEvent12.tasksession_id LEFT JOIN
(select parent_event_id,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_name','imsAuditEventObject12') as OBJECT_NAME,
ca_concat('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.object_type','imsAuditEventObject12') as OBJECT_TYPE,
ca_concat_noseq('imsAuditEventObject12.parent_event_id',parent_event_id,'imsAuditEventObject12.ID','imsAuditEventObject12') as OBJECT_ID
from
imsAuditEventObject12 group by parent_event_id) S1
ON imsAuditEvent12.id = S1.parent_event_id LEFT JOIN
(select
parent_object_id,
ca_concat('parent_object_id',parent_object_id,'attribute_name','imsauditobjectattributes12') as ATTRIBUTE_NAME,
ca_concat('parent_object_id',parent_object_id,'attribute_oldvalue','imsauditobjectattributes12') as ATTRIBUTE_OLDVALUES ,
ca_concat('parent_object_id',parent_object_id,'attribute_newvalue','imsauditobjectattributes12') as ATTRIBUTE_NEWVALUES
from
imsauditobjectattributes12 group by parent_object_id) S2
ON S1.OBJECT_ID = S2.parent_object_id LEFT JOIN
(select
parent_event_id,
ca_concat('parent_event_id',parent_event_id,'OBJECT_DN','imsauditobjectrelationship12') as OBJECT_DN,
ca_concat('parent_event_id',parent_event_id,'OBJECT_TYPE','imsauditobjectrelationship12') as OBJECT_TYPE ,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_NAME','imsauditobjectrelationship12') as CONTAINER_NAME,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_DN','imsauditobjectrelationship12') as CONTAINER_DN,
ca_concat('parent_event_id',parent_event_id,'CONTAINER_TYPE','imsauditobjectrelationship12') as CONTAINER_TYPE
from
imsauditobjectrelationship12 group by parent_event_id) S3
ON imsAuditEvent12.id =S3.parent_event_id where imsauditevent12.id > 0 and imsauditevent12.id <12000 order by imsauditevent12.id ASC;
2. Query without using functions:
select * from imsauditeventobject12 left join imsauditevent12 on imsauditeventobject12.id=imsauditevent12.id left join imsauditobjectattributes12 on imsauditeventobject12.id=imsauditobjectattributes12.parent_object_id left join imsaudittasksession12 on imsauditevent12.tasksession_id=imsaudittasksession12.id left join imsAuditObjectRelationship12 on imsAuditEvent12.id =imsAuditObjectRelationship12.parent_event_id where imsauditevent12.id >0 and imsauditevent12.id < 12000 order by imsauditevent12.id asc;
Thanks,
BadriHi,
Please find the below more information about the query.
DB version: Oracle 11g Enterprise Edition Release 11.2.0.1.0
Below are source of the functions:
create or replace function ca_concat( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str varchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
l_str := '';
open l_cur for 'select '|| ca_other_col_name ||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
l_val := SUBSTR(l_val,0,102);
exit when (l_cur%notfound or l_count > 38);
l_str := l_str || l_sep || l_count || '.' || l_val;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
create or replace function ca_concat_noseq( ca_key_name in varchar2,
ca_key_val in varchar2,
ca_other_col_name in varchar2,
ca_tname in varchar2 )
return varchar2
as
type rc is ref cursor;
l_str nvarchar2(32000);
l_sep varchar2(1);
l_val varchar2(32000);
l_count number(6);
l_cur rc;
begin
l_count :=1;
open l_cur for 'select '||ca_other_col_name||'
from '|| ca_tname || '
where ' || ca_key_name || ' = '
using ca_key_val;
loop
fetch l_cur into l_val;
exit when (l_cur%notfound or length(l_val)>3000 or l_count>1);
l_str := l_str || l_sep || l_val ;
l_sep := ',';
l_count := l_count + 1;
end loop;
close l_cur;
return l_str;
end;
Below are the tables structures:
DESC imsauditevent12;
Name Null Type
ID NOT NULL NUMBER
TASKSESSION_ID NOT NULL NUMBER
TASKSESSION_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
EVENT_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
EVENT_NAME NOT NULL VARCHAR2(255)
EVENT_DESCRIPTION VARCHAR2(4000)
EVENT_STATE VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsauditeventobject12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME VARCHAR2(255)
DESC imsauditobjectattributes12;
Name Null Type
ID NOT NULL NUMBER
PARENT_OBJECT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
DISPLAY_NAME VARCHAR2(255)
ATTRIBUTE_NAME NOT NULL VARCHAR2(255)
ATTRIBUTE_OLDVALUE VARCHAR2(4000)
ATTRIBUTE_NEWVALUE VARCHAR2(4000)
DESC imsaudittasksession12;
Name Null Type
ID NOT NULL NUMBER
PARENT_TS_OID VARCHAR2(100)
PARENT_EVENT_OID VARCHAR2(100)
AUDIT_TIME NOT NULL TIMESTAMP(6)
TASKSESSION_OID NOT NULL VARCHAR2(100)
ADMIN_DN NOT NULL VARCHAR2(512)
ADMIN_NAME VARCHAR2(255)
TASK_NAME VARCHAR2(255)
TASK_TAG NOT NULL VARCHAR2(255)
TASK_DESCRIPTION VARCHAR2(4000)
TASK_PRIORITY NUMBER
STATE NOT NULL VARCHAR2(100)
ENVNAME NOT NULL VARCHAR2(100)
ENV_OID NOT NULL VARCHAR2(100)
DESC imsAuditObjectRelationship12;
Name Null Type
ID NOT NULL NUMBER
PARENT_EVENT_ID NOT NULL NUMBER
AUDIT_TIME NOT NULL TIMESTAMP(6)
OBJECT_TYPE NOT NULL VARCHAR2(100)
OBJECT_DN NOT NULL VARCHAR2(512)
CONTAINER_TYPE NOT NULL VARCHAR2(100)
OBJECT_NAME NOT NULL VARCHAR2(255)
CONTAINER_NAME NOT NULL VARCHAR2(255)
CONTAINER_DN NOT NULL VARCHAR2(512)
OPERATION NOT NULL VARCHAR2(50)
Thanks,
Badri -
SQL column as select statement to be referenced into a group by
Is there a notation or solution to be able to reference a column that is a inline select statement within a group by as detailed below? The group by will not accept the alias. I also tried to make the SQL a MAX to remove the need for the group by reference and this returned invalid expression.
SELECT DISTINCT hdr.BUSINESS_UNIT,
hdr.SESSN_ID,
hdr.STREAM_ROOT_ID,
hdr.SESSN_STS_CD,
hdr.SESSN_CRE_DTTM,
CASE
WHEN C.OPRID <> ' ' THEN C.OPRID
ELSE S.OPERATOR
END OPRID,
strm.QS_APP_CONTEXT,
RECV.QTY_SH_RECVD Quantity_Received,
CASE
WHEN hdr.BUSINESS_UNIT = 'MFG01' THEN MAX(G.MFDS_SGRP_SIZE)
ELSE MAX(S.SESSN_SGRP_SIZE)
END Quantity_Inspected,
MAX(S.QS_VALUEREADING_1) Defect_Count,
CASE
WHEN MAX(S.QS_VALUEREADING_1) = 0 THEN ' '
ELSE MAX(G.MFDS_NAME)
END Characteristic,
MAX(CMNT.QS_COMMENT2) COMMENTS,
strm.INV_ITEM_ID,
itm.DESCR,
strm.WORK_CENTER_CODE,
strm.VENDOR_ID,
*(SELECT V.NAME1 FROM PS_VENDOR V WHERE strm.VENDOR_ID = V.VENDOR_ID AND V.SETID = (SELECT SETID FROM PS_SET_CNTRL_REC*
WHERE RECNAME = 'VENDOR'
AND SETCNTRLVALUE = strm.BUSINESS_UNIT)) VENDOR_NAME,
strm.PRDN_AREA_CODE,
strm.COMPL_OP_SEQ,
strm.PRODUCTION_TYPE,
C.RECEIVER_ID,
C.RECV_LN_NBR,
RECV.PO_ID,
RECV.LINE_NBR,
RECV.SCHED_NBR,
C.PRODUCTION_ID,
C.SERIAL_ID,
C.INV_LOT_ID
FROM PS_QS_SESSN_HDR8 hdr
LEFT OUTER JOIN PS_QS_SESSN_TRACE8 C
ON hdr.BUSINESS_UNIT = C.BUSINESS_UNIT
AND hdr.SESSN_ID = C.SESSN_ID
LEFT OUTER JOIN PS_RECV_INSPDTL_VW RECV
ON C.BUSINESS_UNIT = RECV.BUSINESS_UNIT
AND C.RECEIVER_ID = RECV.RECEIVER_ID
AND C.RECV_LN_NBR = RECV.RECV_LN_NBR
LEFT OUTER JOIN PS_QS_STREAM_ROOT strm
ON hdr.STREAM_ROOT_ID = strm.STREAM_ROOT_ID
AND hdr.BUSINESS_UNIT = strm.BUSINESS_UNIT
LEFT OUTER JOIN PS_QS_STREAM8_VW G
ON strm.STREAM_ROOT_ID = G.STREAM_ROOT_ID
AND strm.BUSINESS_UNIT = G.BUSINESS_UNIT
LEFT OUTER JOIN PS_QS_SUBGROUP S
ON hdr.BUSINESS_UNIT = S.BUSINESS_UNIT
AND hdr.SESSN_ID = S.SESSN_ID
AND S.STREAM_ID = G.STREAM_ID
LEFT OUTER JOIN PS_QS_SESSN_COMM8 CMNT
ON S.BUSINESS_UNIT = CMNT.BUSINESS_UNIT
AND S.SESSN_ID = CMNT.SESSN_ID
AND S.STREAM_ID = CMNT.STREAM_ID
AND C.SAMPLE = CMNT.SAMPLE
LEFT OUTER JOIN PS_MASTER_ITEM_TBL itm
ON itm.INV_ITEM_ID = strm.INV_ITEM_ID
LEFT OUTER JOIN PS_SET_CNTRL_REC cntrl
ON itm.SETID = cntrl.SETID
AND cntrl.RECNAME = 'MASTER_ITEM_TBL'
AND cntrl.SETCNTRLVALUE = strm.BUSINESS_UNIT
WHERE S.QS_VALUEREADING_1 = (SELECT MAX(S2.QS_VALUEREADING_1)
FROM PS_QS_SUBGROUP S2
WHERE S2.BUSINESS_UNIT = S.BUSINESS_UNIT
AND S2.SESSN_ID = S.SESSN_ID
AND S2.STREAM_ID = S.STREAM_ID)
GROUP BY hdr.BUSINESS_UNIT,
hdr.SESSN_ID,
hdr.STREAM_ROOT_ID,
hdr.SESSN_STS_CD,
hdr.SESSN_CRE_DTTM,
C.OPRID,
S.OPERATOR,
strm.QS_APP_CONTEXT,
RECV.QTY_SH_RECVD,
strm.INV_ITEM_ID,
itm.DESCR,
strm.WORK_CENTER_CODE,
strm.VENDOR_ID,
VENDOR_NAME,
strm.PRDN_AREA_CODE,
strm.COMPL_OP_SEQ,
strm.PRODUCTION_TYPE,
C.RECEIVER_ID,
C.RECV_LN_NBR,
RECV.PO_ID,
RECV.LINE_NBR,
RECV.SCHED_NBR,
C.PRODUCTION_ID,
C.SERIAL_ID,
C.INV_LOT_IDHi,
Assign the alias in a sub-query. Then you'll be able to use it wherever you want to, and how many times you want to, in a super-query.
For example:
WITH got_vendor AS
SELECT hdr.business_unit
SELECT v.name1
FROM ps_vendor v
WHERE strm.vendor_id = v.vendor_id
AND v.setid = (
SELECT setid
FROM ps_set_cntrl_rec
WHERE recname = 'VENDOR'
AND setcntrlvalue = strm.business_unit
) AS vendor_name
FROM ps_qs_sessn_hdr8 hdr
SELECT business_unit -- NOTE: no hdr.; all columns are from got_vendor now
, vendor
FROM got_vendor
GROUP BY business_unit
, vendor
;When you define an alias (such as vendor) in a query, you can use that alias in the ORDER BY clause of that same query, but that's the only place in that same query where you can use it. If you want to use the alias anywhere else (e.g., in the GROUP BY clause, as in your example, the WHERE clause, or elsewhere in the SELECT clause), then you probably want to compute it in a sub-query, as shown above.
There's probably a better way to compute vendor, but that's a separate problem.
Edited by: Frank Kulash on Jan 3, 2012 10:37 AM
Added example -
Cross database join Oracle - SQL server date column - nQSError: 46008
Hi,
I am using OBIEE 10.1.3.4.2 and
I am able to make cross database join between Oracle and SQL server using varchar columns, but I am getting this error:
nQSError:22024-A comparison is being carried out between noncompatible type when I try to make "foreign key" join between two tables (one from Oracle, second from SQL Server) using number columns (INT, DOUBLE...). It is strange, but I when I make "complex join" on physical layer no error is thrown and everything works fine.
But I am not able to make join between tables using Date column. Column in Oracle table has DATE datatype, column in SQL server tables has datetimeoffset(7) datatype (example: 2011-07-19 13:14:22.2032605 +02:00). So I tried to cast datetimeoffset(7) to date datatype using "convert(DATE,HappenedOn,120)" - this returns me 2011-07-19 . In this format, BI can show converted date column, I can make filter using this date column, but I am not able to make physical join with Oracle table using this column
Answer using data from both joined tables gives me this error:
[nQSError: 46008] Internal error: File .\DataType\SUKeyCompare.cpp, line 875. (HY000)
Do you have some tips, how to solve this "bug"?Parse the command column to get the SSIS package file name may be your only option here.
-
Import oracle.sql.* use in weblogic env.
hi,
I need to use following in my my java program and deployed in Jdeveloper(11.1.1.)
import oracle.sql.*;
In order to use this in my program, what pre-request installation JAR file I required.
if so send me oracle link for download..
ThanksOracle Jdbc Drivers Download Page: http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-112010-090769.html
With detailed descriptions ...which Driver is compiled on which version of JDK and Size etc.... -
Connecting DB Oracle/SQL server using the same SQL Navigator release 5.1.0
I have
SQL Navigator release 5.1.0.655 installed in my desktop
License version X-pert Edition
Licensed Options
PL/SQL Debugger
CodeXpert
Knowledge Xpert For Pl/SQL
Xper Tuning
Currently I have the access of Oracle DB using this SQL navigator and MS-SQL server using MS-Sql server Query Analyzer
My question is -- using the same SQL Navigator can I connect MS-SQL server DB/Tables and can I run sql query using this..
Thanks in advance.
MashWhy, in an Oracle forum, are you asking a question about a Quest product connecting to a Microsoft product?
How does this relate to the Oracle Database?
Maybe you are looking for
-
Changes in EJB when deployed in JBoss
Hi, We Created the Enterprise Application (EJB Project and WebProject) in the JDeveloper11g preview 1. It is Sucessfully working when it deployed in OC4J application server. I want to deploy the same application in the JBoss. what are the changes i s
-
Hi, I am using the report 'RSDEMO_SPLITTER_CONTROL' to see if i can get an transaction in a part of a screen. In this example that you can see in transaction 'dwdm' - example Splitter Cointainer, we have 2 containers. I want to know if it is possible
-
How do I change my sercuity questions ?, How do I change my sercuity questions ?
Every time I try to but something on the App Store that cost money, it tells me to put in sercuity questions . But I don't know the answers to them. I followed the steps on how to change the questions, but it's not working. I have a recuse email but
-
EXPORT DATA TO EXCEL BY OLE2 VARIANT ARRAY
Hi all, I currently use 10g Forms. but every time have a error FRM-92101 occur when execute when-button-press trigger. anybody know what is the problem occur ? pls find below coding : - PROCEDURE EXP_EXCEL IS TYPE TStrs IS TABLE OF varchar2(1000) IND
-
Mapping FM- RH: Table margins?
When I'm opening my imported FrameMaker documents in RoboHelp, the specified margins (space) before and after the tables (which I have specified in FrameMaker) disappears in RoboHelp. How can I get this right, without having to edit the margins manua