Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Choosing an option when two records are identical

Status
Not open for further replies.

sssu

Technical User
Sep 24, 2003
23
0
0
AU
Hi,
I have two tables.
End of year results Interim results
Date Result Date Result

I've made a union between the two tables, but I want to say that when the dates are equal (but the value of the 'results' won't be)- choose the value of the "End of year results table" and do not diplay the "interim results table" result.

Please help!
 
Sorry. Union doesn't do that. The statements in a UNION are completely separate entities. Think of it this way

(Select * From tblA) UNION (Select * From tblB)

* Runs the tblA query and returns some records
* Runs the tblB query and gets some more records.
* THEN it returns the records from both queries in a single result (but it eliminates duplicate records.)

there is no way to tell the union to conditionally include a record from one query (or not include it) based on some result from the other query. If you want to post your SQL we may be able to figure out how to do what you want.
 
Ok, thanks for your help.
In more detail. I have 3 tables of financial data.
End of year Interim Prelim

Each have the fields 'Date' and 'Value of sales'.

I want to combine all three into a table with just date and value of sales- so i thought i could do a union.

But, sometimes the tables have the same date. Then, I want them to display only the result of the 'end of year table'. Even though the interim or prelim table might have a different result for that date (thus distinct doesn't work because it isn't distinct)

Can i be helped?????
Thank you
 
I can help if you contact me. It sounds like we need some dialogue. Give me a call if you like. I have trick of doing some things, but am not quite sure what youare trying to do

Rick Smith
rsmith@litsllc.com
703-248-7842
 
I'm in Australia- judging by the number your not:)
Do you think you can help at all without dialogue?

Thank you
 
Try this

Select EndOfYear.Date, EndOfYear.ValueOfSales
From EndOfYear InnerJoin Interim ON EndOfYear.Date = Interim.Date InnerJoin Prelim ON EndOfYear.Date = Prelim.Date;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top