ClioSport.net

Register a free account today to become a member!
Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

  • When you purchase through links on our site, we may earn an affiliate commission. Read more here.

SQL Query construction help



Oggy997

ClioSport Club Member
  997.1, Caddy, e208
I'm trying to automate a query from our AS400 using ODBC.

I have two select statements that work independently, however I wish to join them - the statements all come from one table and there are no joins, there also some criteria in the where clause present in both. Can someone advise the best way to structure this query? I've highlighted the below which is the only different field in the two queries being returned, if the second one could be aliased as the first, even better?

select CLNTTH, PAL#TH, TRDTTH, COMMTH, TRNCTH, TRTMTH, TRNQTH, USERTH, LOCNTH, WSIDTH from warhist
where trdtth between 180104 and 180105 and
clntth not like 'D2' AND
trncth in ('7174', '7163', '71 ', ' 31', '7159', ' 51', '1231', '3171', 'LOAD', ' 60', ' 53', 'SHRK', 'LBEL', 'INVE', 'CSPK')
select CLNTTH, PAL#TH, TRDTTH, COMMTH, PROGTH, TRTMTH, TRNQTH, USERTH, LOCNTH, WSIDTH from warhist
where trdtth between 180104 and 180105 and
clntth not like 'D2' AND
progth in ('RDT181', 'RDT325', 'RDT781', 'RDT310') and
Locnth not like '%%O'
and trnqth = 0

Can anyone help me out?
Thanks
 


Top