Hi,
I'm having some difficulty creating a SQL SELECT statement to combine multiple records into one.
Basically using two tables, call'm table1 and table2.
For each record in Table1, there are 6 records in Table2.
Table1 has a bunch of fields amongs ForecastMonth, ForecastYear (both being integers).
Table2 has few fields and each record for a record in Table1 has 6 different months of forecast marked with MonthMM, and YearYYYY.
So for example Table1.Record1 has 6 months of forecast in Table2.Record1, Table2.Record2, Table2.Record3, Table2.Record4, Table2.Record5, Table2.Record6
Would it be possible to create a SELECT statement with nested Select statements where the returned records would be like:
ReturnedRecord1.Table1.Record1.Field1
ReturnedRecord1.Table1.Record1.Field2
ReturnedRecord1.Table1.Record1.Field3
ReturnedRecord1.Table1.Record1.Field4
ReturnedRecord1.Table2.Record1.Field1
ReturnedRecord1.Table2.Record1.Field2
ReturnedRecord1.Table2.Record2.Field1
ReturnedRecord1.Table2.Record2.Field2
ReturnedRecord1.Table2.Record3.Field1
ReturnedRecord1.Table2.Record3.Field2
ReturnedRecord1.Table2.Record4.Field1
ReturnedRecord1.Table2.Record4.Field2
ReturnedRecord1.Table2.Record5.Field1
ReturnedRecord1.Table2.Record5.Field2
ReturnedRecord1.Table2.Record6.Field1
ReturnedRecord1.Table2.Record6.Field2
and then ReturnedRecord2..comes.
By the way, Table1's unique record identifier (SalesForecastID) also exists in Table2, so that is what they could be lookup on. I'm just not familiar with SQL enough to figure out how to combine it all in one statement.
I'm having some difficulty creating a SQL SELECT statement to combine multiple records into one.
Basically using two tables, call'm table1 and table2.
For each record in Table1, there are 6 records in Table2.
Table1 has a bunch of fields amongs ForecastMonth, ForecastYear (both being integers).
Table2 has few fields and each record for a record in Table1 has 6 different months of forecast marked with MonthMM, and YearYYYY.
So for example Table1.Record1 has 6 months of forecast in Table2.Record1, Table2.Record2, Table2.Record3, Table2.Record4, Table2.Record5, Table2.Record6
Would it be possible to create a SELECT statement with nested Select statements where the returned records would be like:
ReturnedRecord1.Table1.Record1.Field1
ReturnedRecord1.Table1.Record1.Field2
ReturnedRecord1.Table1.Record1.Field3
ReturnedRecord1.Table1.Record1.Field4
ReturnedRecord1.Table2.Record1.Field1
ReturnedRecord1.Table2.Record1.Field2
ReturnedRecord1.Table2.Record2.Field1
ReturnedRecord1.Table2.Record2.Field2
ReturnedRecord1.Table2.Record3.Field1
ReturnedRecord1.Table2.Record3.Field2
ReturnedRecord1.Table2.Record4.Field1
ReturnedRecord1.Table2.Record4.Field2
ReturnedRecord1.Table2.Record5.Field1
ReturnedRecord1.Table2.Record5.Field2
ReturnedRecord1.Table2.Record6.Field1
ReturnedRecord1.Table2.Record6.Field2
and then ReturnedRecord2..comes.
By the way, Table1's unique record identifier (SalesForecastID) also exists in Table2, so that is what they could be lookup on. I'm just not familiar with SQL enough to figure out how to combine it all in one statement.