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

x
?
Solved

Compare query where ID's are different

Posted on 2013-12-21
2
Medium Priority
?
260 Views
Last Modified: 2013-12-21
Hi,

I need help with this query. It is to compare pre conversion data to post conversion data. recno = roid + 2000 (meaning that we added 2000 to the roid so the id's would not hit existing records in the target table.

Here is what I have so far:
SELECT
	`tpsmotorsports source`.`orders money`.recno AS recno,
	`tpsmotorsports target`.ledger.roid,        -- is recno + 2000
	`tpsmotorsports source`.`orders money`.taxamt,
	`tpsmotorsports target`.ledger.amount,
	`tpsmotorsports target`.ledger.transactiontype
FROM
	`tpsmotorsports source`.`orders money`
LEFT JOIN `tpsmotorsports target`.ledger ON `tpsmotorsports source`.`orders money`.recno = `tpsmotorsports target`.ledger.roid
WHERE
	transactiontype = 'RO - Taxes Owed'

Open in new window


For this to work I need to have the join factor in the 2000 increase in the roid value. For example recno 1 will be roid 2001. I am not clear on how to do this and what I have tried has failed. Any idea how to make this work?

Thanks,
c
0
Comment
Question by:ckelsoe
[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 Comments
 
LVL 8

Accepted Solution

by:
vr6r earned 2000 total points
ID: 39734146
Have you tried just including the calculation in the join?  Either subtracting 2000 from the roid or adding 2000 to the recno?
Something like this:
LEFT JOIN `tpsmotorsports target`.ledger ON `tpsmotorsports source`.`orders money`.recno = (`tpsmotorsports target`.ledger.roid - 2000)

Open in new window

0
 

Author Comment

by:ckelsoe
ID: 39734154
I did and it returns 0 records. Then I realized I had added 2000 instead of subtract 2000. Another ID10t problem I think.

Thanks for the help!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

610 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