Home » SQL & PL/SQL » SQL & PL/SQL » QUERY GIVING ERROR SQL COMMAND NOT PROPERLY ENDED
QUERY GIVING ERROR SQL COMMAND NOT PROPERLY ENDED [message #7103] Wed, 21 May 2003 06:12 Go to next message
vimal
Messages: 46
Registered: February 2000
Member
hello

friends i m facing very sill problem the below statement run successfully when i union the same with same query it give ora 00933 sql command not properly ended please please help me its urgent

select to_char(post_cd) post, a.emp_Cd ,emp_first_nam||' ' ||emp_mid_nam||' '||emp_sur_nam ,
915 perk_Cd,perk_desc , nvl(sum(nvl(a.amount,0) -nvl( b.amount,0)),0) from
th_payslipdet a , th_payslipdet b , tmd_empdtls d,tmd_employeepay f,
( select 'NET PAY' perk_desc from dual ) g
where a.perk_cd =910
and b.perk_cd =912
and a.month=:month
and b.month=:month
and a.fin_year= :year
and a.proc_typ_ind <> 'ARR'
and b.fin_year= :year
and b.proc_typ_ind <> 'ARR'
and a.emp_Cd=b.emp_Cd
and a.emp_cd = d.emp_Cd
and a.emp_cd= f.emp_cd
and payserial_no =DECODE(:PAYSERIAL_NO,NULL,f.PAYSERIAL_NO,:PAYSERIAL_NO)
group by d.post_cd, a.emp_cd,emp_first_nam||' ' ||emp_mid_nam||' '||emp_sur_nam
order by to_number(post)

union

select to_char(post_cd) post, a.emp_Cd ,emp_first_nam||' ' ||emp_mid_nam||' '||emp_sur_nam ,
915 perk_Cd,perk_desc , nvl(sum(nvl(a.amount,0) -nvl( b.amount,0)),0) from
th_payslipdet a , th_payslipdet b , tmd_empdtls d,tmd_employeepay f,
( select 'NET PAY' perk_desc from dual ) g
where a.perk_cd =910
and b.perk_cd =912
and a.month=:month
and b.month=:month
and a.fin_year= :year
and a.proc_typ_ind <> 'ARR'
and b.fin_year= :year
and b.proc_typ_ind <> 'ARR'
and a.emp_Cd=b.emp_Cd
and a.emp_cd = d.emp_Cd
and a.emp_cd= f.emp_cd
and payserial_no =DECODE(:PAYSERIAL_NO,NULL,f.PAYSERIAL_NO,:PAYSERIAL_NO)
group by d.post_cd, a.emp_cd,emp_first_nam||' ' ||emp_mid_nam||' '||emp_sur_nam
order by to_number(post)

bye
Re: QUERY GIVING ERROR SQL COMMAND NOT PROPERLY ENDED [message #7109 is a reply to message #7103] Wed, 21 May 2003 07:48 Go to previous messageGo to next message
Madhu
Messages: 36
Registered: April 2001
Member
Just remove the order by clause in first query.
Re: QUERY GIVING ERROR SQL COMMAND NOT PROPERLY ENDED [message #517714 is a reply to message #7109] Wed, 27 July 2011 10:22 Go to previous messageGo to next message
shashank_kurasrediffmail
Messages: 63
Registered: July 2011
Location: hyderabad
Member

REMOVE ORDER BY CLAUSE IN BOTH THE QUERRIES OR KEEP THE QUERRIES IN SUBQUERRY


SELECT * FROM (SELECT * FROM EMP WHERE DEPTNO=20 ORDER BY DEPTNO)
UNION
SELECT * FROM (SELECT * FROM EMP ORDER BY DEPTNO)

[Updated on: Wed, 27 July 2011 10:25]

Report message to a moderator

Re: QUERY GIVING ERROR SQL COMMAND NOT PROPERLY ENDED [message #517715 is a reply to message #517714] Wed, 27 July 2011 10:42 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
@shashank_kurasrediffmail
1) Please have a read of the fourm guide, especially point 8.
2) Posting in all caps is considered shouting on all internet forums, please don't do it.
3) This thread is 8 years old. While we appreciate the fact that you're trying to help it would be more useful if you answered questions from this year.
4) Union does a sort, so it can reorder data. Consequently your suggestion won't work.

EDIT: typo

[Updated on: Wed, 27 July 2011 10:51]

Report message to a moderator

Previous Topic: separate date interval by trimester
Next Topic: Grant Alter table
Goto Forum:
  


Current Time: Fri Apr 26 16:54:18 CDT 2024