Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I convert this SQL Statement from SQL Server?

Posted on 2008-10-09
3
Medium Priority
?
2,453 Views
Last Modified: 2012-06-21
I am trying to convert the follow block of SQL from SQL Server to Teradata.

When compiling the code in Teradata, I get the following error:
3654:  Corresponding select-list expressions are incompatible.

How can I edit this code in order for it to compile properly?  Thank you!
select	EXTRACT(year from sold_date) ,
	EXTRACT(month from sold_date) ,
	EXTRACT(year from sold_date)*100+EXTRACT(month from sold_date), 
	ca.loan_num,
	sold_date,
	NULL,
	NULL
from	cmrmkt cr,
	cmacct ca
where	sold_date >= '2007-08-01' 
and	cr.receivable_id = ca.receivable_id
and	ca.loan_num not in (select loan_num from lcnam)
UNION
select	EXTRACT(year from sold_date) ,
	EXTRACT(month from sold_date) ,
	EXTRACT(year from sold_date)*100+EXTRACT(month from sold_date), 
	ca.loan_num,
	sold_date,
	lcm.charge_off_date,
	lcm.charge_off_flag
from 	cmrmkt cr,
	cmacct ca,
	lcnam lcm
where 	sold_date >= '2007-08-01'
and 	cr.receivable_id = ca.receivable_id
and 	ca.loan_num = lcm.loan_num;

Open in new window

0
Comment
Question by:SpeedsterZ28
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Expert Comment

by:Cedric_D
ID: 22682422
try replace two UNION parts...
0
 

Accepted Solution

by:
SpeedsterZ28 earned 0 total points
ID: 22682539
Do you mean get rid of the UNION and just do two INSERT INTO statements for each SELECT statement?
0
 
LVL 7

Expert Comment

by:Cedric_D
ID: 22755149
I mean, try switch these two parts each other, to allow server to know type of last two columns.

To solve this definitely, make explicit cast for all columns of both unions, to desired datatypes.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question