Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Union two queries where one query has a Nullif column
Wed, Apr 15 2015 10:59 AMPermanent Link

Boss

My two queries have two columns each [Schedule_Guid, PaymentFrequency_Id]

Query one is basic

select Schedule_Guid, PaymentFrequency_Id INTO memory\m1 from Schedule1

Query two has a null column

select Schedule_Guid, NULLIF(Schedule_Guid, Schedule_Guid) as PaymentFrequency_Id into memory\m2 from schedule 2

select * from memory\m1 as X
union
select * from memory\m2 as Y

produces this error


DBISAM Engine Error # 11949 SQL parsing error - Expected NULL, Boolean, SmallInt, Word, AutoInc, Integer, LargeInt, Currency, Float, or BCD expression but instead found PaymentFrequency_Id in SELECT SQL statement

May I ask how would I union the null column?
Wed, Apr 15 2015 1:09 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Try this for query 2



select Schedule_Guid, '' as PaymentFrequency_Id into memory\m2 from schedule 2


'' and NULL are equivalent in DBISAM and using '' tells it that the field is a string. You might need to cast it as the same length as the field you're tring to union it with eg

select Schedule_Guid, CAST('' AS STRING(10)) as PaymentFrequency_Id into memory\m2 from schedule 2

Roy Lambert
Image