× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello all,

Having an issue with an SQL statement. This is my first attempt at using
the UNION statement but I don't think that's where the problem is. The
error I get is:

"Column OHDTCR or expression in SELECT list not valid"

Here's the thing.....where this OHDTCR field is being used seemed to work
fine before I added the UNION clause, so I'm not sure how the adding of it
made it become a problem. OHDTCR is a numeric field, by the way. Any
thoughts from the group would be MOST appreciated. Thanks!

Bill

select substr(digits(dec(19000000+ohdtcr,8,0)),5,2) as monthcreated,
substr(digits(dec(19000000+ohdtcr,8,0)),1,4) as yearcreated,
ohbrch, wxidfm,
count(wxidfm)
as FamilyTot
from bapdata.oeohdp
join bapdata.oeodtp on ohbrch =
odbrch and ohordr = odordr
join bapdata.wnfitp on oditem = wxitem
where ohorty = 'W' and ohstat = ' '
and odstat = ' '
and (substring(odfl15,4,1) = 'Y' or ohordr > 1000000)
and odprgp = 'REG4'
and wxidfm in ('JAWN','JBAY','JCAS','JDHG','JPIC','JSHG','JSLD','JSP
C','JTCAS') and ohbrch <> 16


union

select substr(digits(dec(19000000+ohdtcr,8,0)),5,2) as monthcreated,
substr(digits(dec(19000000+ohdtcr,8,0)),1,4) as yearcreated,
ohbrch, wxidfm,
count(wxidfm)
as FamilyTot
from baphst.oeohdp
join baphst.oeodtp on ohbrch =
odbrch and ohordr = odordr
join bapdata.wnfitp on oditem = wxitem
where ohorty = 'W' and ohstat = ' '
and odstat = ' '
and (substring(odfl15,4,1) = 'Y' or ohordr > 1000000)
and odprgp = 'REG4'
and wxidfm in ('JAWN','JBAY','JCAS','JDHG','JPIC','JSHG','JSLD','JSP
C','JTCAS') and ohbrch <> 16

group by substr(digits(dec(19000000+ohdtcr,8,0)),1,4),
substr(digits(dec(19000000+ohdtcr,8,0)),5,2), ohbrch, wxidfm
order by ohbrch, wxidfm, substr(digits(dec(19000000+ohdtcr,8,0)),1,4),
substr(digits(dec(19000000+ohdtcr,8,0)),5,2)

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.