| | |
Oracle Query Help Needed
Please support our Oracle advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
Hello Folks,
I'm a not an expert in Oracle/SQL Server query and need some guidence and help from the professionals.
Basis for my challange is that I have two tables that i need to collect data from. The main table is ACTIVITIES...secondary table is CODESET...
Fields (column) To collect/ are...
TABLE: ACTIVITIES
*COLUMN: SEQ
*COLUMN: AN
*COLUMN: NET_ID
COLUMN: DES
COLUMN: R11
TABLE: CODESET
*COLUMN: CODE
*COLUMN: CONFIG_ID
*COLUMN: RFIELD_NR
COLUMN: SHORT
Fields marked '*' are primary keys. Field R11 are foreign key in ACTIVITIES Table and point to CODE in CODESET Table.
TABLEDATA (ACTIVITIES):
AN | NET_ID | DES | R11
TOP10 | 510 | TASKNAME 1 | 6
TOP11 | 511 | TASKNAME 2 | 7
TABLEDATA (CODESET):
CODE | CONFIG_ID | RFIELD_ID | SHORT
6 | 272 | 11 | YEAR 2008
6 | 273 | 11 | YEAR 2004
7 | 272 | 11 | YEAR 2009
7 | 273 | 11 | YEAR 2005
THE GOAL IS TO GET THE SHORT (DESCRIPTION) IN THE ACTIVITIES TABLE QUERY. Not sure what's the best way to do this, sub-query or join query.
Any help highly appreciated.
-Parlati
I'm a not an expert in Oracle/SQL Server query and need some guidence and help from the professionals.
Basis for my challange is that I have two tables that i need to collect data from. The main table is ACTIVITIES...secondary table is CODESET...
Fields (column) To collect/ are...
TABLE: ACTIVITIES
*COLUMN: SEQ
*COLUMN: AN
*COLUMN: NET_ID
COLUMN: DES
COLUMN: R11
TABLE: CODESET
*COLUMN: CODE
*COLUMN: CONFIG_ID
*COLUMN: RFIELD_NR
COLUMN: SHORT
Fields marked '*' are primary keys. Field R11 are foreign key in ACTIVITIES Table and point to CODE in CODESET Table.
TABLEDATA (ACTIVITIES):
AN | NET_ID | DES | R11
TOP10 | 510 | TASKNAME 1 | 6
TOP11 | 511 | TASKNAME 2 | 7
TABLEDATA (CODESET):
CODE | CONFIG_ID | RFIELD_ID | SHORT
6 | 272 | 11 | YEAR 2008
6 | 273 | 11 | YEAR 2004
7 | 272 | 11 | YEAR 2009
7 | 273 | 11 | YEAR 2005
THE GOAL IS TO GET THE SHORT (DESCRIPTION) IN THE ACTIVITIES TABLE QUERY. Not sure what's the best way to do this, sub-query or join query.
Any help highly appreciated.
-Parlati
Last edited by parlati; Jul 24th, 2009 at 4:51 am. Reason: Table data not properly seperated with spaces
Just use a join query. Sub query to just pull fields is not required.
sql Syntax (Toggle Plain Text)
SELECT a.Seq, a.An, a.NET_Id, a.DES, b. Short FROM Activities a, Codeset b WHERE a.R11 = b.code
Last edited by peter_budo; Jul 24th, 2009 at 2:53 pm. Reason: Correcting closing tag
•
•
Join Date: Jul 2009
Posts: 2
Reputation:
Solved Threads: 0
Thanks for the message. A join with a.R11=b.code is not sufficient -
because field CODESET.Code is not unique - primary fields field include code, config_id and rfield_nr. I was thinking about a join with select case - but not sure how yet. I still in process to work out something. If you already know - i very much appreciate your help.
Kind regards,
Parlati
because field CODESET.Code is not unique - primary fields field include code, config_id and rfield_nr. I was thinking about a join with select case - but not sure how yet. I still in process to work out something. If you already know - i very much appreciate your help.
Kind regards,
Parlati
I am not quite sure what you want your final result to look like?
The join i provided would give you the following result
TOP10 | 510 | TASKNAME 1 | 6 | YEAR 2008
TOP10 | 510 | TASKNAME 1 | 6 | YEAR 2004
TOP11 | 511 | TASKNAME 2 | 7 | YEAR 2009
TOP11 | 511 | TASKNAME 2 | 7 | YEAR 2005
If you can give me an example of what you want the final result to be I can help you find the solution.
Rob
The join i provided would give you the following result
TOP10 | 510 | TASKNAME 1 | 6 | YEAR 2008
TOP10 | 510 | TASKNAME 1 | 6 | YEAR 2004
TOP11 | 511 | TASKNAME 2 | 7 | YEAR 2009
TOP11 | 511 | TASKNAME 2 | 7 | YEAR 2005
If you can give me an example of what you want the final result to be I can help you find the solution.
Rob
![]() |
Similar Threads
- SQL query help needed (Database Design)
- Mysql Query needed (MySQL)
- Query Needed (MySQL)
- SQL Query Help needed! (MS SQL)
- Oracle PressEbook needed (Oracle)
- Sr Oracle DBA needed in Tampa Bay 6 months -to- Perm (Software Development Job Offers)
- perl script help re: scope/structure for noob (Perl)
Other Threads in the Oracle Forum
- Previous Thread: ODisplay Language
- Next Thread: multiple data insertion
Views: 423 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for Oracle
2009predictions acquisition amazon.com bartz bernanke cia citrix cloudcomputing crm database dell economy editor enterprise enterprise2.0 enterprisesoftware erp federalreserve forbes hp ibm intellipedia internet larryellison layoffs linux loughridge mediawiki michaeljackson microsoft neverland nortel notebooks oil operatingsystem oracle palm rimm saas salesforce sap seagate socialcomputing sql sun sybase technologystocks virtualiron virtualization vmware wiki wikipedia xen yahoo zoho





