I have two tables that have been joined into a single table. The first table contains primary key Customer Number and Customer Name. The second table contains a foreign key Customer Number and Location Number. There can be multiple locations for each customer. When I join these two tables with
Select Table1.CustomerNumber, Table1.CustomerName, Table2.LocationNumber from Table1, Table2 where Table1.CustomerNumber = Table2. CustomerNumber
I get a new table with three columns, Customer Number Customer Name and Location with a repeating Customer Number and Name for each location.
Is it possible with a query to turn this into a table with a single row for each customer number and name with a column for each location? The total number of columns would be determined by the customer with the most locations and those with fewer locations would have a null value for the unfilled columns.
Here is the example results:
Start with:
Cus# Name Location
1 John 1
1 John 2
1 John 3
2 Mike 4
2 Mike 5
3 Bob 6
With miracle query:
Cus# Name Loc1 Loc2 Loc3
1 John 1 2 3
2 Mike 4 5 null
3 Bob 6 null null
Thanks for any help!
Kyle
Select Table1.CustomerNumber, Table1.CustomerName, Table2.LocationNumber from Table1, Table2 where Table1.CustomerNumber = Table2. CustomerNumber
I get a new table with three columns, Customer Number Customer Name and Location with a repeating Customer Number and Name for each location.
Is it possible with a query to turn this into a table with a single row for each customer number and name with a column for each location? The total number of columns would be determined by the customer with the most locations and those with fewer locations would have a null value for the unfilled columns.
Here is the example results:
Start with:
Cus# Name Location
1 John 1
1 John 2
1 John 3
2 Mike 4
2 Mike 5
3 Bob 6
With miracle query:
Cus# Name Loc1 Loc2 Loc3
1 John 1 2 3
2 Mike 4 5 null
3 Bob 6 null null
Thanks for any help!
Kyle