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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating 2 tables from one on the fly - mind draws a blank

Status
Not open for further replies.

jimineep

Technical User
May 16, 2006
20
GB
Hi guys,

I am currently writing a complicated script (perl) to do something I feel I could do with one SQL command:

I have a table -

EXP_NAME ID CHANGE

A AX 234.23
A AB -23.23
A AC 22.23
B AX -43.25
B BZ 233.75
B AC -77.23

Basically I want to pull out all of the data for the rows where the ID's match between the EXP_NAMEs, so in this case A AX with B AX, A AC with B AC, A AB and B BZ would be ignored since they do not match.

This would be trivial if the EXPs were in different tables, but they're not!

Cheers,
 
all you have to do is write the query as though they were ;-)
Code:
select one.EXP_NAME   
     , one.ID    
     , one.CHANGE
     , two.CHANGE
  from atable as one
inner
  join atable as two
    on two.EXP_NAME = one.EXP_NAME  
   and two.ID       = one.ID

r937.com | rudy.ca
 
Hmm not working, its throwing back:

from TABLE_NAME as one
*

ERROR at line 5:
ORA-00933: SQL command not properly ended

Might be an oracle thing...?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top