subquery returns no row in the main query, but hard returns the value of the master query
Oracle 11g, Solaris SPARC 64-bit:
This is the master query: its not to return all the lines
Select count (*) in the sadmin.usr_mods where to_char (ts_id) in ((select to_char (rtrim (ltrim(TS_MODULES,','), ',')) in the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3));
COUNT (*)
----------
0
But wherever if I use subquery only returns he lines:
SQL > select rtrim (ltrim(TS_MODULES,','), ',') from the sadmin.usr_rfc where TS_KINTANA_PACKAGE_NUMBER = '123' and ts_projectid = 3;
RTRIM (LTRIM(TS_MODULES,','), ',')
--------------------------------------------------------------------------------
49,54
If I use these values as hardcoded to a select master it will return 2 rows:
SQL > select count (*) in the sadmin.usr_mods where to_char (ts_id) in ('49 ', ' 54');
COUNT (*)
----------
2
TS_MODULES datatype is CLOB
TS_ID datatype is set to number
Help, please
with
usr_rfc as
(select 3 ts_projectid, 123 ts_kintana_package_number, to_clob(',49,54,') ts_modules
of the double
),
usr_mods as
(select ts_id 49 Union double all the)
Select 50 in all double union
Select double 54
)
Select count (*)
of usr_mods
where to_char (ts_id) in (select regexp_substr (to_char (rtrim (ltrim(TS_MODULES,','), ',')),'[^,] +', 1, level))
of usr_rfc
where TS_KINTANA_PACKAGE_NUMBER = '123'
and ts_projectid = 3
connect by level<= regexp_count(to_char(rtrim(ltrim(ts_modules,','),',')),',')="" +="">=>
)
COUNT (*) |
---|
2 |
Concerning
Etbin
Select count (*)
of usr_mods
where instr ((select ',' | to_char (rtrim (ltrim(TS_MODULES,','), ',')) |)) ','
of usr_rfc
where TS_KINTANA_PACKAGE_NUMBER = '123'
and ts_projectid = 3
),
',' || TO_CHAR (TS_ID) | ','
) > 0
Tags: Database
Similar Questions
-
Subquery returns the same value but no returnet lines
HY all
First of all excuse me for my English. I know that is very bad.
I have a very annoying problem...
I habe a query like this
Select the car of cars where car_color = (select color color where car_id = '5452')
My real Qery is mor complicated, but this is how it works.
Now the problem:
If I run the first query select car of cars where car_color = 'black' the query returns a value.
If I run the subquery *(select color from Colors where car_id ='5452') * the subquery returns a value (black)
If I run the query and subquery select car of cars where car_color = (select color color where car_id = '5452')
I get no value :(
How this bee? If I take the (black) result of the subquery, and paste of STIs in the first request, then I get a value.
But if I use the two querys it works.
Thank you for your support
Welcomes Burillouser13568585 wrote:
I can see that the results are not the same, but how can it happen?
Without your thing, I'll never be able to see the problem. Toad is really stupid as I think?It has nothing to do with the toad. You will get the same results in SQL * more. Most of the tools on the client side display the nonprinting characters such as spaces. And in your case, string returned by the subquery has had new line at the end. Anyway, the other way to understand would compare dumps of returned strings:
select DUMP(LTRIM(RTRIM(rem.PSTREM_KURZ_BEZ))) from p_pveps_episode eps, p_pvrep_re rep, p_strem_rechempf rem WHERE eps.allmnd_mandant='Test' and eps.ppveps_aufnr='101224' and eps.allmnd_mandant=rep.allmnd_mandant and eps.ppveps_epsnr=rep.ppveps_epsnr and rep.pstrem_ident=rem.pstrem_ident -- {and ltrim(rtrim(rem.PSTREM_KURZ_BEZ)) =} quotet to show result
SY.
-
return the empty record only when no results not returned by the main query
It is a question of SQL (not PL/SQL)...
Let's say I have the following text:
Full_name SELECT NULL, NULL, NULL last_update_date address
OF the double
UNION ALL
SELECT full_name, address, last_update_date
Employees
WHEN TRUNC (sysdate) = TRUNC (last_update_date)
If the second part of the query retrieves no rows, it works beautifully and I get a blank line; However, if the second part of the query returns records, I get a blank line over my dataset I want.
How can I create a SQL statement that executes only the first query (before the union all) when no result is returned from the second. Also, I don't want to exceute the query twice only if I can get a count of the records because my actual query is much more complex than the example I've provided here.
Thanks in advance!
EmilyHello
You can try to use a subquery factoring (WITH clause)
The query is executed only once, the query results are cached in memory or in a temporary table.
and you can view these results several times in the main query:WITH second_query AS ( -- your second query here SELECT full_name, address, last_update_date FROM employees WHERE TRUNC(sysdate)=TRUNC(last_update_date) ) SELECT full_name, address, last_update_date FROM second_query UNION ALL SELECT NULL full_name, NULL address, NULL last_update_date FROM dual WHERE NOT EXISTS ( SELECT 1 FROM second_query)
Published by: kordirko on 2010-07-08 02:02
-
Simple query with a subquery returns the result of 'bad '.
DB version: 11.2
We have created approximately 27 patterns in the last 4 days. The query below confirms that.
DBA_TS_QUOTAS.max_bytes column, we can determine the quota of space allocated for a user/schemaSQL > select username, created from dba_users where created > sysdate-4; USERNAME CREATED ------------------------------ -------------------- MANHSMPTOM_DEV_01 12 Jul 2012 11:55:16 PRSM01_OAT_IAU 13 Jul 2012 01:51:03 F_SW 11 Jul 2012 17:52:42 FUN_CDD_HK_SIT 09 Jul 2012 15:33:57 CEMSCOMPTOM_UAT_01 12 Jul 2012 11:43:45 STORM02_OAT_IAU 13 Jul 2012 02:06:29 . . 27 rows selected. -------------> Truncated output
So, I wanted to see the space allocated for users created in the last 4 days. The following query should return only 27 cases because the subquery returns only 27 records. Instead, he returned 66 entries!SQL > desc dba_ts_quotas Name Null? Type ----------------------------------------- -------- ---------------------------- TABLESPACE_NAME NOT NULL VARCHAR2(30) USERNAME NOT NULL VARCHAR2(30) BYTES NUMBER MAX_BYTES NUMBER BLOCKS NUMBER MAX_BLOCKS NUMBER DROPPED VARCHAR2(3)
No idea why? I know this isn't a bug with oracle. It's just that I didn't eat fish lately.select username, tablespace_name, max_bytes/1024/1024 quotaInMB from dba_ts_quotas where username in (select username from dba_users where created > sysdate-4);
Hello
J.Kiechle wrote:
So, I wanted to see the space allocated for users created in the last 4 days.DBA_TS_QUOTAS does not have the space, but rather the maximum allowed for a given user.
J.Kiechle wrote:
The following query should return only 27 cases because the subquery returns only 27 records. Instead, he returned 66 entries!What happens if your user John has Quotas on 3 tablespace TBS1 and TBS3 and TBS2?
You can't expect the outer query to retrieve only the more than 27 just line because the inner query returns 27 rows.For the space allocated by the storage space for newly created users, you'd better ask dba_segments. something like:
select owner, tablespace_name, trunc(sum(bytes)/1024/1024) alloc_mb from dba_segments where owner in (select username from dba_users where created > sysdate - 4) group by owner, tablespace_name order by owner, tablespace_name;
-
Help in the treatment of "subquery returns multiple rows.
Appreciate your help on this.
I have under sql query fails with the error "ORA-01427: einreihig subquery returns multiple lines"
WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT distinct col2 FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 WhenI checked the count using below query WITH t AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'E', 'F', 'G' FROM DUAL UNION SELECT 'A', 'T', 'U' FROM DUAL), t1 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'D1', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL UNION SELECT 'S', 'V', 'W' FROM DUAL), t2 AS (SELECT 'A' Col1, 'B' Col2, 'C' Col3 FROM DUAL UNION SELECT 'A', 'E1', 'F1' FROM DUAL UNION SELECT 'D', 'E', 'F' FROM DUAL) SELECT t.col1, (SELECT count(col2) FROM t2 WHERE t2.col1 = t.col1) RND_COL FROM t, t1 WHERE t.col1 = t1.col1 (+) it shows as below ----------------- COL1 RND_COL A 2 A 2 D 1 E 0 My Requirement is for all the values in the column 'RND_COL' > 1 it should display text as 'Multiple', for 'RND_COL' = 1 display actual value returned by sub query and 'RND_COL' = 0 display it as NULL. expected output ------------------- COL1 RND_COL A Multiple A Multiple D E E NULL
Hello
Here's another way. It's like the solution in response #1, but it does not use a subquery:
SELECT t.col1
CASE
WHEN COUNT (DISTINCT t2.col2) > 1
THEN "Multiple."
For ANOTHER MIN (t2.col2)
END AS rnd_col
T
LEFT OUTER JOIN t2 ON t2.col1 = t.col1
GROUP OF t.col1, t.col2, t.col3
ORDER BY t.col1
;
This assumes that in table t (col1, col2, col3) combination is unique. If theat is not the case, change the GROUP BY clause, but you need to ensure that all lines of t becomes a separate group.
-
How to write a query to return rows with the varchar column that contains even a single occurrence of the characters, such as Ÿ and
I have a table whose columns with values such as
MINNEAŸPOLIS and ¿VV ¿A
Only the characters that are allowed in this column are alphabets, numbers, spaces, points and supports.
Please help to write a SQL SELECT with Regexp_like query or any other option.
Thanks to you all! Under query worked for me. Thank you Frank to explain the concept of hooks inside regexp_like.
SELECT * FROM testspecial, WHERE REGEXP_LIKE (sampletext, "[^] ^ A - Z ^ a - z ^ 0-9 ^ [^.]") ^ {^} ^]') ;
-
Einreihig subquery returns more than one query
Hello
I get the following error: einreihig subquery returns more than one request. I don't know how I should debug this application. As far as I know, subqueries can return only 1 row...: S
I've only Oracle SQL Developer to run/test of my queries. I can run the query with ROWNUM < 5000, which gives no error. If I run with ROWNUM > 5000 and ROWNUM < 6000 then the error pops up...
This is the query:
Published by: layout of the code user574699 on November 17, 2008 02:10with DATES as (select (select min(REC_DATE) from STOCK) as FROM_DT, (select max(CHANGE_DATE) from STOCK_ADJUST) as TO_DT from DUAL), MONTHS as (select add_months(trunc(FROM_DT,'MM'),ROWNUM-1) as DT from DATES connect by ROWNUM <= months_between(TO_DT, FROM_DT)+1), CALCULATIONS as (select PNM.PNM_AUTO_KEY PNM_KEY, MONTHS.DT DT, NVL((select sum(stm.qty_rec) from stock stm WHERE STM.REC_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY GROUP BY pnm_auto_key),0) INCOMING, NVL((select sum(saj.qty_adj) from stock_adjust saj inner join stock stm on saj.stm_auto_key = stm.stm_auto_key inner join parts_master pnm on stm.pnm_auto_key = pnm.pnm_auto_key where SAJ.CHANGE_DATE < MONTHS.DT AND STM.PNM_AUTO_KEY = PNM.PNM_AUTO_KEY group by pnm_auto_key),0) OUTGOING from MONTHS, PARTS_MASTER PNM) SELECT ROWNUM, CALCULATIONS.PNM_KEY PNM_AUTO_KEY, CALCULATIONS.DT COUNT_DATE,CALCULATIONS.INCOMING QTY_RECEIVED, CALCULATIONS.OUTGOING QTY_USED, (CALCULATIONS.INCOMING + CALCULATIONS.OUTGOING) QTY_BALANCE FROM CALCULATIONS;
the problem is that you use the same alias in your view online as well as in your main query in the second statement-nvl...
HTH
-
DECODE does not work in the WHERE clause when subquery returns more than one line
Hi gurus,
I want to write a query against the table CCENTERS (Script given below) and wait for the following result:
1. in the transition from a value of 0 for the ID, it returns all the rows in the table.
2. in the passage of one value other than 0, it returns the row corresponding to the given value and all its records of the child.
CCENTER has parent-child relationship in the column ID and the BASE. I use a query with the DECODE function. but the function in the WHERE clause is not capable of managing the subquery with multiple lines of DECODE.
*************************************************
VARIABLE ParaCCenter NUMBER
BEGIN
: paraccenter: = 0;
END;
/
CREATE TABLE ccenters
(id NUMBER,
name VARCHAR2 (20).
number base);
INSERT INTO ccenters VALUES(1,'NUST',null);
INSERT INTO ccenters VALUES(2,'SEECS',1);
INSERT INTO ccenters VALUES(3,'NBS',1);
commit;
SELECT * from ccenters
WHERE id IN DECODE(:ParaCCenter, 0, id,)
(SELECT id FROM ccenters
START WITH basic =: ParaCCenter
ID of CONNECTION BY PRIOR = base
UNION
SELECT: ParaCCenter OF double
)
)
/
BEGIN
: paraCCenter: = 1;
END;
/
SELECT * from ccenters
WHERE id IN DECODE(:ParaCCenter, 0, id,)
(SELECT id FROM ccenters
START WITH basic =: ParaCCenter
ID of CONNECTION BY PRIOR = base
UNION
SELECT: ParaCCenter double))
/
The result is
(SELECT id FROM ccenters
*
ERROR at line 3:
ORA-01427: einreihig subquery returns multiple rows
How this query can be rewritten for the given feature. Any response will be appreciated.
Thank youTry something like this:
SELECT * FROM ccenters WHERE :ParaCCenter = 0 OR id in (SELECT id FROM ccenters START WITH base=:ParaCCenter CONNECT BY PRIOR id = base UNION SELECT :ParaCCenter FROM dual )
-
Single - row subquery returns more than one line.
Hi Experts
I am faced with error
ORA-01427: single - row subquery returns more than one line.
MyQuery is:
select TO_CHAR(T.MR_REG_DATE,'DD') "DATE" ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END age ,count(T.Mr_Code) No_of_Patient ,( SELECT count(x.mr_code) mr_code FROM HMIS_MRINFO X where X.mr_reg_date between &FRM_DATE AND &TO_DATE and X.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y WHERE Y.mr_reg_date between &FRM_DATE AND &TO_DATE ) GROUP BY CASE WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(X.MR_REG_DATE,X.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ) Missing_MR from hmis_mrinfo T,hmis_pat_add_dis_detail M where T.mr_code = M.mr_code(+) and T.mr_reg_date between &FRM_DATE AND &TO_DATE &AGE_GRP GROUP BY T.MR_REG_DATE ,CASE WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) between 0 and 1 THEN ' 01'||' - ('||'0 - 1 Month)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02'||' - ('||'2 - 12 Months)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03'||' - ('||'1 - 5 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04'||' - ('||'5 - 10 Years)' WHEN trunc((MONTHS_BETWEEN(T.MR_REG_DATE,T.MR_DOB))) > 120 then ' 05'||' - ('||'> 10 Years)' END ORDER BY T.MR_REG_DATE;
Please give some advice / solution.
I think this might do it for you
Select
TO_CHAR (T.MR_REG_DATE, 'DD') "DATE."
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
Age of the END
count (T.Mr_Code) No_of_Patient
, count (case when t.mr_code NOT in (select Y.mr_code from hmis_pat_add_dis_detail Y))
WHERE Y.mr_reg_date between & FRM_DATE AND & TO_DATE)
then t.mr_code
(end) Missing_MR
of hmis_mrinfo T, hmis_pat_add_dis_detail M
where T.mr_code = M.mr_code (+)
and between T.mr_reg_date & FRM_DATE AND & TO_DATE
& AGE_GRP
T.MR_REG_DATE GROUP
CASE
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) between 0 and 1 THEN ' 01' |'. - ('||' 0-1 month)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 2 AND 12 THEN ' 02' |'. - ('||' 2-12 months)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 13 AND 60 THEN ' 03' |'. - ('||' 1-5 years)"
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) BETWEEN 61 AND 120 THEN ' 04' |'. - ('||' 5-10 years)'
WHEN trunc ((MONTHS_BETWEEN (T.MR_REG_DATE, T.MR_DOB))) > 120 then ' 05' |'. ' - ('| ' > 10 years).
END
ORDER BY T.MR_REG_DATE;
-
How to filter records in a main query of RDF based on the values of the calculated fields
Hello
I'm working on a report of RDF, where I have my main request which has four fields.
(1) the unique id for the field
(2) numerical value 1
(3) numeric value 2
(4) numeric value 3
I added a CF_Total of calculated field.
The main query returns all the records, but I want to only show that these fields for which the CF_Total has a particular value.
Can anyone help me about how to proceed.
Concerning
Hawker
Hello Hawker,
This is an example, how you can filter based on the formula column. I don't know exactly where you would use. And other related issues.
Give the idea and example how you can start.
Thank you
Hamid
-
Returns all duplicate rows, where the columns correspond
Dear members,
I have a table that contains duplicates, and the query should return only the rows where the columns correspond...
create master table (varchar2 (10) firstname, lastname varchar2 (10), code VARCHAR2 (3), place varchar2 (10));
insert into Master values ('bob', 'John', '1', 'atlanta');
insert into Master values ('bob', 'John', '1', 'atlanta');
insert into Master values ('bob', 'John', '1', 'atlanta');
insert into Master values ('test', 'John', '1', 'atlanta');
Insert into master values('bob','john','1','bank');
The application should we 3 rows.
Bob-john-1-atlanta
Bob-john-1-atlanta
Bob-john-1-atlanta
I tried a few changes to query such as select * from master M, mater n where m.firstname = n.firstname and...
Is there another way to do this...
Thanks in advance...select firstname, lastname, code, place from ( select m.*, count(*) over(partition by firstname,lastname,code,place) cnt from master m ) where cnt > 1 order by firstname, lastname, code, place / FIRSTNAME LASTNAME COD PLACE ---------- ---------- --- ---------- bob john 1 atlanta bob john 1 atlanta bob john 1 atlanta SQL>
SY.
-
einreihig subquery returns multiple rows
Hello
In the sub query, I get the error "ORA-01427: einreihig subquery returns more than one line. In this query below, I must also display only the bsr_ind_id from rm_cust where are.bsr_borr_ctg_id = '1' and also all cust_name and client_id
How can I modify this query?
Select cust_name
client_id
, (select bsr_ind_id from rm_cust r where are.bsr_borr_ctg_id = '1') as "SSB".
of rm_custI haven't used the pivotal enough to help with that without doing some research which I do not have time for this moment. But back to your original problem: there is obviously more than 1 line in rm_cust with bsr_borr_ctg_id = '1', so what one do you? You can guarantee that you will not get the error if you use:
select cust_name ,client_id ,(select max(bsr_ind_id) from rm_cust r where r.bsr_borr_ctg_id = '1') as "BSR" from rm_cust
Or you can use min max. Either avoid the error you get. If both give you the same result, then that is what you need. If they give different results, then you need to determine what (if) is correct.
-
Query with a subquery should return a value but does not work
When I run this SQL, it does not return value:
SELECT vfn.cat
OF vfn, valid_fishery vf vps_fishery_ner
WHERE vfn.plan = vf.plan
AND vfn.cat = vf.cat
AND vf.permit_year = 2010
AND vf.moratorium_fishery 't ='
AND vfn.vp_num = 211652
AND vfn.ap_year = 2010
AND vfn.plan = 'MUL '.
AND vfn.date_issued = (SELECT MAX (date_issued)
OF vps_fishery_ner
WHERE vp_num = 211652
AND ap_year = 2010);
To test, I remove the subquery and run it separately:
SELECT MAX (date_issued)
OF vps_fishery_ner
WHERE vp_num = 211652
AND ap_year = 2010;
Returns 2 April 10
Then I paste the date into the original query (using her TRUNCATES the function, of course, since I'm only part DDMMYY hardcode the date):
SELECT vfn.cat
OF vfn, valid_fishery vf vps_fishery_ner
WHERE vfn.plan = vf.plan
AND vfn.cat = vf.cat
AND vf.permit_year = 2010
AND vf.moratorium_fishery 't ='
AND vfn.vp_num = 211652
AND vfn.ap_year = 2010
AND vfn.plan = 'MUL '.
AND TRUNC (date_issued) = TO_DATE('02-APR-10');
And returns the required value, "A".
So why the complete query with a subquery does not work, if the value returned by the subquery is valid and works when you just pasted in there?
Thank you.Hello
Maybe you should include this in the subquery as well?
AND vfn.plan = 'MUL'
-
updated - einreihig subquery returns multiple rows
I'm trying to update the values in a column in a table to match the value in a table of validation/look-up. Why do I get an error with this sql?
UPDATE TABLE_A
SET field_x = (SELECT field_x
OF TABLE_B, TABLE_A
WHERE TABLE_A.field_Y = TABLE_A.field_Y)
WHERE THERE ARE
(SELECT field_x
OF TABLE_B, TABLE_A
WHERE TABLE_A.field_Y = TABLE_A.field_Y)
I get the error "einreihig subquery returns several lines.
I can run the subquery only without any problem.
ideas?Hello
You get this error becauseYour request
SELECT field_x FROM TABLE_B, TABLE_A WHERE TABLE_A.field_Y = TABLE_A.field_Y
Returns a value greater than 1 for field_x.
You may wan to check your data.Now, it depends entirely on your data if the following query will work ok or not?
Try thisUPDATE TABLE_A SET field_x = (SELECT field_x FROM TABLE_B WHERE TABLE_A.field_Y = TABLE_A.field_Y) WHERE EXISTS (SELECT field_x FROM TABLE_B WHERE TABLE_A.field_Y = TABLE_A.field_Y)
Kind regards
BobinPublished by: Buga added second query
-
Hi all
We try to add new proposal for a salary of some employees from form August 1, 2015 (the Date of the beginning of employee)
There is no existing salary proposal doesn't exist for these employees.
We get below error.
ORA-01422: exact fetch returns more than the requested number of rows in the hr_maintain_proposal_swi procedure insert_salary_proposal package
Help, please.
Thank you
Tarun
Hi John,.
If it helps, take a look at the following note:
ORA-01422 exact Fetch returns more than number of lines requested in Hr_maintain_proposal_swi (Doc ID 1673527.1)
Kind regards
Rajen
Maybe you are looking for
-
Health after app updated iOS at level 10, can't enter manually blood sugar longer?
After the upgrade to iOS 10 can I enter is no longer blood sugar? I followed my blood sugar every day for years. It seems now there is no way to do it manually. WHA' happened?
-
The executable font size different from that in the enrironment of LabVIEW Development
I created an executable of LabVIEW, but the size of the font used in the executable file is different from the original font used in the labVIEW development environment. How to solve this problem? Thank you. Ian
-
Print color photos appear under the name of b & w, as soon as I hit
Color photos are suddenly appear in black and white as soon as I hit 'Print' and print in b & w only! It is a new issue for me.
-
Cannot delete 'Ownership' of the contextual right click Menu.
Hello. I need help 'Take Ownership' remove from my right-click context Menu. I forgot how I put it on, (and), and now I need help he was taking off. Thank you. ~ Mystery.
-
I bought the first Adobe pro and was not able to download
I'm not able to find the link to my purchased version of the first pro