Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My 'Union Query is throwing Unknown Command 1

Status
Not open for further replies.

VijiKumara

Programmer
Mar 13, 2018
17
US
SQL:
Select  Distinct L.NM_LINE, D.nm_fac, S.TRANSFORMER_OPER_ID, S.FEEDER_NUMBER, S.INDUSTRIAL, S.COMMERCIAL, S.RESIDENTIAL, S.TOTAL
 from 
          amp.tb_line L,  
          amp.tb_sect K,  
          amp.site D,
          amp.trits.feeder_customer S
where K.cd_stat = 'C' and l.cd_stat = 'C'
         and K.ik_line = L.ik_line  
          and D.ik_site = K.ik_site_end 
           and  D.nm_fac = S.SUBSTATION_NAME
UNION
select  Distinct L.NM_LINE, D.nm_fac, S.TRANSFORMER_OPER_ID, S.FEEDER_NUMBER, S.INDUSTRIAL, S.COMMERCIAL, S.RESIDENTIAL, S.TOTAL
from 
          amp.tb_line L,  
          amp.tb_sect K,  
          amp.site D,
          amp.trits.feeder_customer S
where K.cd_stat = 'C' and l.cd_stat = 'C'
         and K.ik_line = L.ik_line  
          and D.ik_site = K.ik_site_beg;
            and  D.nm_fac = S.SUBSTATION_NAME;

Following is the result i am getting(Please refer to the image attachment)

Error_xtl8ug.png
 
Hi,

Do each of the Select queries run to completion independently?

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Remove the semicolon in the second but last line "and D.ik_site = K.ik_site_beg;" perhaps?

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Thank you much, folks. I executed both the queries separately and also I removed the extra semicolon I added. It worked. You guys are simply awesome.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top