SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Not getting back data from 1 column.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

AdamWest
Constraint Violating Yak Guru

USA
351 Posts

Posted - 08/16/2013 :  15:28:39  Show Profile  Reply with Quote
Here after the Union, the col. WWDTA should have data but its' coming back blanks, but all cols are aligned.
why is this?

SELECT
ALL T01.OHORD#, T01.OHSLR#,T01.OHORDT, T01.OHORDD,
T01.OHTTN$, '' as WWDTA
FROM ASTDTA.OEORHDOH T01,
ASTDTA.OETRANOT T02
WHERE T01.OHORD# = T02.OTORD#
AND( T02.OTTRNC = 'WOC')
and T01.OHORDD > 20120101
UNION ALL
SELECT
ALL T01.OHORD#, T01.OHSLR#, T01.OHORDT, T01.OHORDD,
T01.OHTTN$,
SUBSTR(RFDTA,1,20) AS WWDTA
FROM ASTCCDTA.WOCREPS T01,
ASTCCDTA.REPREF1 T02
WHERE T01.OHSLR# = T02.RFSLC

Edited by - AdamWest on 08/16/2013 15:34:22

James K
Flowing Fount of Yak Knowledge

3568 Posts

Posted - 08/16/2013 :  15:58:33  Show Profile  Reply with Quote
quote:
Originally posted by AdamWest

Here after the Union, the col. WWDTA should have data but its' coming back blanks, but all cols are aligned.
why is this?

SELECT
ALL T01.OHORD#, T01.OHSLR#,T01.OHORDT, T01.OHORDD,
T01.OHTTN$, '' as WWDTA
FROM ASTDTA.OEORHDOH T01,
ASTDTA.OETRANOT T02
WHERE T01.OHORD# = T02.OTORD#
AND( T02.OTTRNC = 'WOC')
and T01.OHORDD > 20120101
UNION ALL
SELECT
ALL T01.OHORD#, T01.OHSLR#, T01.OHORDT, T01.OHORDD,
T01.OHTTN$,
SUBSTR(RFDTA,1,20) AS WWDTA
FROM ASTCCDTA.WOCREPS T01,
ASTCCDTA.REPREF1 T02
WHERE T01.OHSLR# = T02.RFSLC

In Microsoft SQL Server, the query should return data if there is anything in RFDTA column. However, SUBSTR is not a T-SQL function.

If you are using Oracle, this may not be the right forum. Most people here are good at Microsoft SQL Server, but very few if any Oracle experts. You might try dbforums.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

India
22744 Posts

Posted - 08/18/2013 :  11:20:03  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
That blanks should come from the first part of the UNION ALL. However you would have values in the second part. Try executing only the second part to confirm it

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.25 seconds. Powered By: Snitz Forums 2000