01427 00000 - "einreihig subquery returns several lines.
Hi allHow can I solve it
SELECT
v.code
,v.bar_code
,v.arb_name
,v.eng_name
,v.branch_no
,(SELECT sum(quantity) FROM viw_whs_items_movement GROUP BY branch_no)
FROM viw_whs_items_movement V
This code gives me this error01427 00000 - "einreihig subquery returns several lines.
I know that I have more value, but I need this value
Result group
SELECT sum(v.quantity)
FROM viw_whs_items_movement v
GROUP BY v.branch_no
##########################
SUM(V.QUANTITY)
---------------
114453
2501
8137
13270
15230
120626
22536
2926
12848
37509
20911
7503
6248
17221
462
24
15041
10307
12524
526627
10564
8230
13204
2840
80769
1418238
215694
15238
5063
104187
913
147079
11293
12678
18855
35 rows selected
Must be scalar subqueries. You demonstrate your subquery returns more than one line. Where the error.
A solution would be to establish a correlation between the results of the subquery by joining the branch_id with branch_id of the outer query. However, as the two queries use the same table, you can simply use an analytical SUM():
SELECT
v.code
,v.bar_code
,v.arb_name
,v.eng_name
,v.branch_no
,sum(quantity) over (partition by branch_no) as branch_tot
FROM viw_whs_items_movement V
Cheers, APC
Tags: Database
Similar Questions
-
ORA-01427 single row subquery return several rows.
It's my request. Something wrong with this request... ?
UPDATE OT_QUOT_COMP_MRN MNR
SET THE MNR. LINKS_1 = (SELECT IN. LINKS TO MNR, OT_QUOT_COMP_PO PO OT_QUOT_COMP_MRN WHERE MRN.) LINKS IS IN.. VOUCHER_NO
AND IN. LINKS LIKE 'QTN %' AND THE MNR. LINKS_1 NOT LIKE '% QTN %')
WHERE EXISTS (SELECT IN. LINKS TO OT_QUOT_COMP_PO IN. WHERE MNR.) LINKS = IN. VOUCHER_NO AND IN. LINKS LIKE 'QTN %' AND THE MNR. LINKS_1 NOT LIKE '% QTN %')
Thank you and best regards!
DevaPerhaps update a join
update (select mrn.links_1 x_links_1,po.links y_links from ot_quot-comp_po po, ot_quot_comp_mrn mrn where po.voucher_no = mrn.links and instr(po.links,'QTN') > 0 and instr(mrn.links_1,'QTN') = 0 ) set x_links_1 = y_links
-
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
-
"ORA-01427: einreihig subquery returns more than one line.
Hi all
I have a SQL query where I need a subquery for certain fields (like fields are optional), and the thing is some of the subqueries are works well, but when I use some, it gives me an error * "ORA-01427: einreihig subquery returns more rows" *, so I looked to the top of the internet and found if I give *' and rownum = 1' * in the subquery ". It eliminates the error and there certainly, but the thing is I have test the XML data. I have two addresses that should appear on the report and both follow the same path, but one is required optional and another so I put the option in the subquery, but in the XML data, I see that both addresses are the same, but they need to be different, because the status of the relationship with that I question is different. I ALSO POST MY SQL so that if anyone of you has an idea can help out me. Once more, the sql, I put here has the SQL subqueries with ' and rownum = 1', which gives me bad output
Select S_FN_INCEXP_CON. RELATION_TYPE_CD as RELATION_TYPE_CD,
S_ORDER. ORDER_NUM as ORDER_NUM,
S_ORDER. FRGHT_AMT as FRGHT_AMT,
S_ORDER. ORDER_DT as ORDER_DT,
S_ORDER. CARRIER_CD as CARRIER_CD,
S_ORDER. CARRIER_PRIO_CD as CARRIER_PRIO_CD,
S_ORDER. ACCNT_ORDER_NUM as ACCNT_ORDER_NUM,
S_CONTACT. FST_NAME as FST_NAME,
S_CONTACT. Last_name like LAST_NAME,
S_ADDR_PER. ADDR_NAME as ADDR_NAME-> it's the address required
S_ADDR_PER. POSTAL CODE such as POSTAL code,
S_CON_ADDR. ADDR_MAIL_CD as ADDR_MAIL_CD,
S_ADDR_PER. EMAIL_ADDR as EMAIL_ADDR,
S_ADDR_PER. PH_NUM as PH_NUM,
S_SRC_PAYMENT. PAYMENT_NUM as PAYMENT_NUM,
S_ORDER. STATUS_CD as STATUS_CD,
(select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
of SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD! = ALL ('Donor', 'Notified Party', ' in memory of ', ' in honor of ')) RELATION_TYPE_CD_1
, (select S_CONTACT_1.FST_NAME |') '|| S_CONTACT_1.LAST_NAME
of SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD! = ALL ('Donor', 'Notified Party', ' in memory of ', ' in honor of ')) NAME.
(select S_ORDER_TYPE.NAME
of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
and S_ORDER_TYPE.NAME = 'Général'), GENERAL
(select S_ORDER_TYPE.NAME
of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
and S_ORDER_TYPE.NAME = 'Memory') MEMORY,
(select S_ORDER_TYPE.NAME
of SIEBEL. S_ORDER_TYPE S_ORDER_TYPE
where S_ORDER. ORDER_TYPE_ID = S_ORDER_TYPE. ROW_ID
and S_ORDER_TYPE.NAME = 'Honour') HONOR,.
(select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
of SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in memory of ') R1,.
(select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
of SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in honor of ") R2,.
(select S_FN_INCEXP_CON_1.RELATION_TYPE_CD
of SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = 'notified Party') R3.
(select S_ADDR_PER. ADDR_NAME | ',' | S_ADDR_PER. Zip code
of SIEBEL. S_ADDR_PER S_ADDR_PER,
SIEBEL. S_CON_ADDR S_CON_ADDR,
SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_CONTACT. ROW_ID = S_CON_ADDR. CONTACT_ID
and S_CON_ADDR. ADDR_PER_ID = S_ADDR_PER. ROW_ID
and rownum = 1
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD IN 'Notified Party') NP_ADDR-> it's the optional address
(select S_PARTY_REL. REL_TYPE_CD
of SIEBEL. S_PARTY_REL S_PARTY_REL,
SIEBEL. S_CONTACT S_CONTACT_1,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON_1
where S_ORDER. ROW_ID = S_FN_INCEXP_CON_1.FN_INCM_EXP_ID
and S_FN_INCEXP_CON_1.CONTACT_ID = S_CONTACT_1.ROW_ID
and S_PARTY_REL. REL_PARTY_ID = S_CONTACT_1.ROW_ID
and S_FN_INCEXP_CON_1.RELATION_TYPE_CD = ' in memory of ') RLNSHIP
of SIEBEL. S_CONTACT S_CONTACT,
SIEBEL. S_FN_INCEXP_CON S_FN_INCEXP_CON,
SIEBEL. S_ORDER S_ORDER,
SIEBEL. S_ADDR_PER S_ADDR_PER,
SIEBEL. S_CON_ADDR S_CON_ADDR,
SIEBEL. S_SRC_PAYMENT S_SRC_PAYMENT
where S_ORDER. ROW_ID = S_FN_INCEXP_CON. FN_INCM_EXP_ID
and S_FN_INCEXP_CON. CONTACT_ID = S_CONTACT. ROW_ID
and S_CONTACT. ROW_ID = S_CON_ADDR. CONTACT_ID
and S_CON_ADDR. ADDR_PER_ID = S_ADDR_PER. ROW_ID
and S_FN_INCEXP_CON. RELATION_TYPE_CD = 'donor '.
and S_SRC_PAYMENT. ORDER_ID = S_ORDER. ROW_IDUse
' and S_CONTACT_1.ROW_ID = S_CON_ADDR. CONTACT_ID'
your 3rd condition in where clause.So it would be to get the address of the 'notified part' information instead of the donor
-
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.
-
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
-
Hi Jeff,
I use the ai2 since September 13 and I got this error when I run several reports from the RAC (2 knots) databases.
For ex. in the DBA Panel, according to the Performance option, when I try to launch ASHES for las 5 minutes, the ORA-01427 out immediately.
I want just to be sure you're already aware of this problem and taken into account for the next version.
Thanks in advance,
Andraly Ng
EA3 just came out a few hours ago - have a go at it and let us know what you think!
-
ORA-01427: einreihig subquery returns multiple rows
I've been off queries running for awhile, and this error is making me take what I left little hair. I searched and found a lot of topics about this, but it does not appear to meet this request. Rather than continue blabbering...
SELECT THE DME. ITEM_Description, IMPC. ITEM_NUM
Y2006 as Sum2006, Y2007 as Sum2007, Y2008 as Sum2008, as Sum2009, as Sum2010 Y2010 Y2009
,(Select Y2011)
of TestDB.Book_Sect02_ImpleCosts, TestDB.Book_Sect02_ImpleDesc
where recommended = 'PM' and BUDGETTYPE = 'MDY' and BUDGETFY = 2016
and shareby = 'ME' and recommended in (select TestDB.Book_Recommendations recommended)
and Book_Sect02_ImpleCosts.ITEM_NUM = Book_Sect02_ImpleDesc.ITEM_NUM
and Book_Sect02_ImpleDesc.Item_Description = DME. Item_Description) as Sum2011
OF IMPC, TestDB.Book_Sect02_ImpleDesc DME TestDB.Book_Sect02_ImpleCosts
WHERE the recom = 'PM' and BUDGETTYPE = 'DMY' and BUDGETFY = 2016
and shareby = 'ME' and recommended in (select TestDB.Book_Recommendations recommended)
and IMPC. ITEM_NUM = DME. ITEM_NUM
ORDER OF IMPC. ITEM_NUM;
Basically, I want to find and eliminate the duplicate line, but I'm not. The other problem is, I have no direct access to the database. I am a contractor and must be based on e-mailing a DBA Government to execute the query for me. Thank you in advance.
Considering the hoops I need to jump through to solve this problem, it is clear to me... the error does not occur, with the same query on my Production System and it does on my Test System. I have requested that data be deleted at the Test and updated with Production data. I hope that this will solve the problem. I need to keep the data, because it's test, so hopefully this will allow me to move forward. Thank you all for your help.
-
Update TBL to TBL (ORA-01427 ' row subquery returned more line ")
Hello...
I'm new in this stuff and need a little help... Thank you very much for your answers!
I have the error ORA-01427 when run this script:
Update tblproduct
the value (instock) = (select b2.instock - tblproduct b2, b1, b3 tblorder tblitem b1.quantity
where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid to 3025)
The main purpose of the script is the actualization of the butts of the inventory when the order is completed.
The TBLITEM primary key (ORDERID and PRODUCTID). This prevents repeat the question on the agenda.
The structure of tables are:
1. (TBLITEM)
Name Null? Type
---------------------------------- -------------- ---------------
PRODUCTID NOT NULL NUMBER (10)
ORDERID NOT NULL NUMBER (10)
QUANTITY NOT NULL NUMBER (10)
PRICE FLOAT (126)
ITEMID NUMBER (5)
2. (TBLPRODUCT)
Name Null? Type
----------------------------------------- --------------- --------------------
PRODUCTID NOT NULL NUMBER (10)
PRODNAME NOT NULL VARCHAR2 (25)
DESCRIPTION VARCHAR2 (255)
PRICE NOT NULL NUMBER (7.2)
NUMBER (7.2) TAX
STATUS NOT NULL VARCHAR2 (25)
NUMBER (10) NOT NULL INSTOCK
REORDERPOINT NOT NULL NUMBER (10)
DATE OF RESTOCKDATE
CATEGORYID NOT NULL NUMBER (10)
VENDOR NUMBER NO. (10)
2. (TBLORDER)
Name Null? Type
----------------------------------------- ------------ ----------------
ORDERID NOT NULL NUMBER (10)
NOT NULL ORDERDATE DATE
DATE OF ORDERCOMPT
USERID NOT NULL NUMBER (10)
ACCOUNTID NOT NULL NUMBER (10)
STATUS NOT NULL VARCHAR2 (25)
NUMBER (2) CANCELLED
THANKS FOR YOUR HELP ONCE AGAIN!
Published by: user10084733 on April 20, 2009 12:25It is the right way to update your table.
update tblproduct b2 set (instock) = (select b2.instock - b1.quantity from tblitem b1, tblorder b3 where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid in 3025) where exists ( select 1 from tblitem b1, tblorder b3 where b1.productid = b2.productid and b1.orderid = b3.orderid and b3.orderid in 3025) ; Without the where condition you are updating the full table.
-
Why this sql returns ORA-01427: einreihig subquery returns multiple rows.
Select
case when 'Y'=(select emp_sw
of the customer
where cust_co_num = :custconum )
then ( Select cust_id from )
client where
cust_co_num = :custconum
)
on the other
(select...)
end while pays_id
of the double
or any other solution for this?
Thank you!!
Maybe
with
data in the form of
(select cust_id 100, 'Y' emp_sw, 1 cust_co_num of all the double union)
Select 200, "n", 1 Union double all the
Select 300, 'Y', 3 double Union all
Select 400, ', 2 double
)
Select cust_id, emp_sw, cust_co_num
data d
where cust_id = case when exists (select null
from the data
where cust_co_num =: custconum
and emp_sw = 'Y '.
)
then cust_id
end
or cust_id in (select cust_id
from the data
where cust_co_num =: custconum
and emp_sw = n
)
Concerning
Etbin
-
Error: einreihig subquery returns multiple rows
Hai All
I have two tables namely Daily_attend, Train_mast
The Daily_attend are made up of fields are Train_mast are made up of fields are
Name varchar form no var
Date of empcode Num V_DATE
Intimate Date Train_name var
Outtime date Late_hrs var
Number IND_IN
Number IDE_OUT
Date of Attend_date
I need to update the table Depend of IDE_IN in Daily_attend in late_hrs in the Train_mast table
I got through in the select statement, it is my select statement
Select to_number (TO_DATE (TO_CHAR(Intime,'DD-MON-YYYY') |)) » '||
To_char (0815, '0000'), 'MON-DD-YYYY HH24') + late_hrs /(24*60)-respondent
) * 24 * 60 dail_Att, train_mast;
How can I convert to update
Any help is highly appricateable
Thanks in advance
Concerning
Srikkanth.M
Published by: Srikkanth.M on April 13, 2010 10:21If empcode is the primary key in your table of daily_att and attend_date = V_DATE returns only one row per employee
then try this
update dail_att d set d.idein =(select to_number(TO_DATE(TO_CHAR(Intime,'DD-MON-YYYY')||' '|| TO_CHAR(0815,'0000'),'DD-MON-YYYY HH24:MI')+late_hrs/(24*60)-intime) * 24*60 from dail_Att,train_mast where attend_date =t_date AND empcode = d.empcode)
Kind regards
Prazy -
Update of several lines using the join condition
Hi all
CREATE OR REPLACE
PROCEDURE update_t
IS
BEGIN
SheikYerbouti IN (SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME FROM hr.employees)
LOOP
UPDATE
HR.employees1
SET
FOCA =)
Select concat (FIRST_NAME, LAST_NAME) in the hr.employees where SheikYerbouti. EMPLOYEE_ID = 197);
END LOOP;
END update_t;
/
I'm trying to update column Foca Employees1 table. When I run this procedure, I get the error
Error report:
ORA-01427: einreihig subquery returns multiple rows
ORA-06512: at "SYSTEM. UPDATE_T", line 13
ORA-06512: at line 1
01427 00000 - "einreihig subquery returns several lines.
Please let me know a solution for this.
Thank you
MathonHello Mathieu,
in your internal SQL result set is not limited to just one line.
Try thisUPDATE hr.employees1 SET FIRST_LAST= (select concat(FIRST_NAME,LAST_NAME) from hr.employees where emp_rec.EMPLOYEE_ID=hr.employees.employee_id);
Your version had no restrictions on selected lines of hr.employees. You gave a where condition clause that is not related to the query.
The best solution for your problem is to avoid completely any PL/SQL loop. You can try something like this:
update (select e1.first_last, e.first_name, e.last_name from hr.employees1 e1, hr.employees e where e1.employee_id=e.employee_id) set first_last=first_name||last_name;
But beware, the updates on the joints work only under certain restrictions. The key of the table to be updated must be the join key. (key preserved is the word to look for).
Hope that helps,
dhalek -
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.
-
Insert the statement with the subquery to insert several lines
Hi friends,
Please find below mentioned query and error. Also suggest me to go forward.
SQL > INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,
2 TDOC_TRAN_CODE,
TDOC_ACNT_YEAR 3,.
TDOC_CUR_NO 4,.
TDOC_MAX_NO 5,.
TDOC_CAL_YEAR 6,.
TDOC_PERIOD 7,.
TDOC_DIVN_CODE 8,.
TDOC_DEPT_CODE 9,.
TDOC_CR_UID 10,
TDOC_CR_DT 11,
TDOC_UPD_UID 12,
13 TDOC_UPD_DT)
14 SELECT '001',
15 (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE
16 '6',
17 '0',
18 '9999',
19 NULL,
20 NULL,
21 NULL,
22 NULL,
23 "AGT,"
24 TO_DATE (SYSDATE),
25 NULL,
26 TO_DATE (SYSDATE) FROM DUAL;
(SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE),
*
ERROR on line 15:
ORA-01427: einreihig subquery returns multiple rows
+Untested.
When values except 'TDOC_TRAN_CODE' are hardcoded, there is no need to select double.
Something like that?
INSERT INTO FM_TRAN_DOC_NO)
TDOC_COMP_CODE,
TDOC_TRAN_CODE,
TDOC_ACNT_YEAR,
TDOC_CUR_NO,
TDOC_MAX_NO,
TDOC_CAL_YEAR,
TDOC_PERIOD,
TDOC_DIVN_CODE,
TDOC_DEPT_CODE,
TDOC_CR_UID,
TDOC_CR_DT,
TDOC_UPD_UID,
TDOC_UPD_DT
)
SELECT DISTINCT
'001',
TDOC_TRAN_CODE,
« 6 »,
'0',
"9999",
NULL,
NULL,
NULL,
NULL,
"AGT,"
TO_DATE (SYSDATE),
NULL,
TO_DATE (SYSDATE)
OF FM_TRAN_DOC_NO;
-
Newbie needs help.
My SQL statement returns multiple lines, but even after reading the manual I can't understand yet how to use the IN, ALL or PART of the operators to make several lines.
Version:
BANNER
Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
AMT for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
Update proj_assigned
Set project_cost = (select job_charge_per_hour * proj_assigned hours_allocated);
RESULT: einreihig subquery returns multiple rows
Edited by: 996465 03/28/2013 10:47Update proj_assigned
Set project_cost = (select job_charge_per_hour * proj_assigned hours_allocated);In the above sub query you select all lines. Use where clause so that it chooses the only record in the subquery.
Or
You can modify the query, if you want to update project_cost in the Proj_assigned table as below
Update proj_assigned set project_cost = job_charge_per_hour * hours_allocated;
Maybe you are looking for
-
Why DigiCert always shows up on top of security certificates?
I understand that Firefox now blocks all DigiCert security certificates. I use certificate patrol to monitor and compare certificates. Why am I still see some DigiCert certificates? (I keep Firefox updated)
-
With the help of DVD Recovery Win7 to bring satellites L850 - 1 9 'Out of the Box "?
HelloI am using the recovery DVD for my Satellite - 1 9, PSKDLE L850, to replace my HD in the State. Even if the hidden partition was here, I always had errors, e.g. F3-F200-0002.But it wasn't the only one.Right now, I'm wiping the HD to give it the
-
Dear all, I am under domain, Active Directory and the backup server (Backup Exec) and called to account quick book on the same server. Does make all the problems? Kindly looking for answers.
-
Z1: issues installing Windows 10 on Z1
Trying to update my Z1 (G1) to 10 Windows with a clean install. I tried to follow the steps described in the following article: HP - upgrade to Windows 10 workstations; However, all attempts make changes in BIOS in "Steps to take before upgrading" h
-
I'm new to labview and work on a project that accepts the biotic data. I have read the information and analysis data correctly but when I try to set up the number the polarity and decimal pt do not seem to be correct. When the polarity is negative, a