Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Not getting back data from 1 column.

Author  Topic 

AdamWest
Constraint Violating Yak Guru

360 Posts

Posted - 2013-08-16 : 15:28:39
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

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-16 : 15:58:33
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

22864 Posts

Posted - 2013-08-18 : 11:20:03
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
   

- Advertisement -