DELETE CUSTSEGCONTROL.x FROM CUSTSEGCONTROL x, CUSTSEGCONTROL y
WHERE x.custsegcontrolid < y.custsegcontrolid
AND x.customerid = y.customerid
AND tripid='A2G0G5'
AND registrationstatus!=3;
I'm getting this error message.
Error starting at line 1 in command: DELETE x FROM CUSTSEGCONTROL x, CUSTSEGCONTROL y WHERE x.custsegcontrolid < y.custsegcontrolid AND x.customerid = y.customerid AND tripid='A2G0G5' AND registrationstatus!=3
Error at Command Line:1 Column:9
Error report: SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
I think your problem is in this line:
DELETE CUSTSEGCONTROL.x
It seems you are trying to delete column x from CUSTSEGCONTROL, which is invalid.
Try this:
delete custsegcontrol x
where x.customerid in
( select y.customerid
from custsegcontrol y
where x.custsegcontrolid < y.custsegcontrolid
and tripid = 'A2G0G5'
and registrationstatus != 3
)
The following version should work in Oracle. Ironically, this won't work in MySQL:
DELETE FROM CUSTSEGCONTROL x
WHERE EXISTS (SELECT 1
FROM CUSTSEGCONTROL y
WHERE x.custsegcontrolid < y.custsegcontrolid AND
x.customerid = y.customerid AND
tripid = 'A2G0G5' AND
registrationstatus <> 3
);
Related
My query is like
create table abc as select * from (select x, (CASE WHEN ( y != '' and y is not null) THEN y ELSE z END ) AS testColumn from table1) q where q.testColumn is not null;
Whenever I am running this. It is giving me
SemanticException Line 0:-1 Invalid function 'IS NOT TRUE'
If I remove create table from the beginning it works, if I change column name from testColumn to x it works, if I change create table to insert into it works.
What is wrong with create table?
Thanks in advance.
There are redundant (), I guess it causes error. Also y != '' and y is not null is redundant because if y != '', it can not be NULL, so, y != '' is enough.
create table abc as
select *
from
(select x,
CASE WHEN y != '' THEN y ELSE z END AS testColumn
from table1
) q
where q.testColumn is not null;
There had been patching on our cluster, due to which it was not working.
To make it work I need to set a property
set hive.cbo.enable=false;
After doing this my query worked.
While executing the below code:
select distinct tam.sol_id||'|'||(select sol.sol_desc from sol where sol.sol_id=tam.sol_id)||'|'||count(*)||'|'||sum(org_tran_amt)
||'|'||count(case when ott.tran_date between '01-02-2021' and '24-02-2021' as 1 else 0 end) a
from ott,tam
where tam.acid=ott.acid
and tam.gl_sub_head_code in ('85300','85320','85330','85340','85350','85360','85365','85370','85380','85390','85395')
and tran_date <= '24-02-2021'
and tam.sol_id in (select sst.sol_id from sst where sst.set_id='ROFPZ')
and not exists (select * from tct where tct.tran_date=ott.tran_date and trim(tct.tran_id)=trim(ott.tran_id)
and nvl(ott.org_tran_amt-tct.AMT_OFFSET,0)='0' and tct.entity_cre_flg='Y' and tct.del_flg='N');
received below error message as output:
from ott,tam
*
ERROR at line 3:
ORA-00905: missing keyword
Try to modify the case part of the statement:
case when ott.tran_date between '01-02-2021' and '24-02-2021' then 1 else 0 end
You must write "then" instead of "as".
oracle query This works
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
);
but when adding 'where b > 2' makes an error, why?
select *
from (
select to_number(substr(app_cluster,6,2), '99') as b
from xtern_app_info
WHERE app_cluster IS NOT NULL
AND APP_CLUSTER <> 'CLUSTER'
) where b > 2;
ORA-29913: error in executing ODCIEXTTABLEFETCH callout
ORA-01722: invalid number
29913. 00000 - "error in executing %s callout"
*Cause: The execution of the specified callout caused an error.
*Action: Examine the error messages take appropriate action.
I am trying to calculate commission and according to that commission value (commiss) i want to update a column value fixed_fee
select st1.* ,(st1.order_item_value * st1.commission_rate)/100 commiss ,
if commiss < 50 then
update payment_error set fixed_fee = -5 where commiss <= 50
else if commiss >= 50 then
update payment_error set fixed_fee = -10 where commiss >=50
else
end if
from payment_error as st1 join payment_error as st2 on st1.order_item_id=st2.order_item_id ;
while running is then error come is :
ERROR: syntax error at or near "<"
LINE 2: if commiss<50 then
^
********** Error **********
ERROR: syntax error at or near "<"
SQL state: 42601
Character: 87
You can't use if in SQL. This is only available in procedural languages like PL/pgSQL.
But more importantly you cannot embed an update statement inside a select statement like that.
What you are trying to do can be done with a single UPDATE statement using a CASE:
update payment_error
set fixed_fee = case
when (order_item_value * commission_rate)/100 <= 50 then -5
else 5 --<<< different value here
end;
You are setting the fixed_fee to -5 in both cases - I assume that is a typo, and you do mean to assign a different fee for the case when the comission is greater than 50
You cannot use update and select together. To update you can try this:
update payment_error
set fixed_fee = case when (order_item_value * commission_rate * .01) < 50 then -5
else 5 --In your case you have use both as -5 so change it as per your reqm
I have a sql like this
UPDATE A
SET A.TEMSILCI_KOD = 4
FROM S_MUSTERI A, S_TEKLIF B
WHERE A.TEMSILCI_KOD = 9
AND B.BAYI_KOD = 17
AND A.HESAP_NO = B.HESAP_NO
But i getting an error like this
Error starting at line 8 in command:
UPDATE A
SET A.TEMSILCI_KOD = 4
FROM S_MUSTERI A, S_TEKLIF B
WHERE A.TEMSILCI_KOD = 9
AND B.BAYI_KOD = 17
AND A.HESAP_NO = B.HESAP_NO
Error at Command Line:9 Column:22
Error report:
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
Where is the ERROR?
Maybe something like
UPDATE S_MUSTERI
SET TEMSILCI_KOD = 4
WHERE TEMSILCI_KOD = 9
AND EXISTS (SELECT 1 FROM S_TEKLIF B
WHERE S_MUSTERI.HESAP_NO = B.HESAP_NO
AND B.BAYI_KOD = 17)
In Oracle the syntax to update a view is different from SQL*Server's syntax. In Oracle you could issue the following query:
UPDATE (SELECT A.TEMSILCI_KOD
FROM S_MUSTERI A, S_TEKLIF B
WHERE A.TEMSILCI_KOD = 9
AND B.BAYI_KOD = 17
AND A.HESAP_NO = B.HESAP_NO)
SET TEMSILCI_KOD = 4
Note: This query will only work in Oracle if (S_TEKLIF.BAYI_KOD, S_TEKLIF.HESAP_NO) is unique (so that the update will not be ambiguous and each row from S_MUSTERI will be updated at most once).
Your update statement does not follow the correct syntax. There is no from clause in the update statement. It should follow the format
Update <table>
set <column> = <value>
where <conditions>
See this documentation on update:
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10007.htm#i2067715