I'm new to Oracle and I have the data I need linked together in 8 tables.
Region (RegionCode, RegionDesc)
Customer (CustomerNo, CustomerName, RegionCode)
OrderHeader (CustomerNo, OrderNo, OrderDate)
OrderDetail (OrderNo, ProdNo)
OrderHistoryHeader (CustomerNo, OrderNo, OrderDate)
OrderHistoryDetail (OrderNo, ProdNo)
Product (ProdNo, ProdDesc, SubGroupCode, SubCategoryCode)
CodeDesc (Code, CodeDesc)
SubGroupCode and SubCategoryCode are both linked to the Code field in the CodeDesc table. I know this is a bad design as the earlier database designer should have separated Group and Category into two different tables. Below is the list of columns I want:
1) RegionDesc
2) CustomerNo
3) CustomerName
4) ProdCode(from both the OrderDetail and OrderHistory table)
5) ProdDesc
6) CodeDesc(for SubGroup)
7) CodeDesc(for SubCategory)
I want this dataset as a result from one SQL statement, not two. I'm at a lost as how to write the SQL statement for this. I cannot change the structure of the database. Can someone please help? Thanks in advance.
Region (RegionCode, RegionDesc)
Customer (CustomerNo, CustomerName, RegionCode)
OrderHeader (CustomerNo, OrderNo, OrderDate)
OrderDetail (OrderNo, ProdNo)
OrderHistoryHeader (CustomerNo, OrderNo, OrderDate)
OrderHistoryDetail (OrderNo, ProdNo)
Product (ProdNo, ProdDesc, SubGroupCode, SubCategoryCode)
CodeDesc (Code, CodeDesc)
SubGroupCode and SubCategoryCode are both linked to the Code field in the CodeDesc table. I know this is a bad design as the earlier database designer should have separated Group and Category into two different tables. Below is the list of columns I want:
1) RegionDesc
2) CustomerNo
3) CustomerName
4) ProdCode(from both the OrderDetail and OrderHistory table)
5) ProdDesc
6) CodeDesc(for SubGroup)
7) CodeDesc(for SubCategory)
I want this dataset as a result from one SQL statement, not two. I'm at a lost as how to write the SQL statement for this. I cannot change the structure of the database. Can someone please help? Thanks in advance.