Collapsing results to a single row.
Collapsing results to a single row.
(OP)
Hello,
Question about formatting my query results.
I have a customer table and a customer_phone table linked by customer_id field.
When I select records from customer_phone for a particular customer_id I get as many rows as the customer has phone numbers.
For example
select * from customer_phone where customer_id = 123;
Yeilds
Customer_Id Phone
123 123-345-4567
123 123-345-9987
123 123-345-2232
What I would like is to be able to collapse that to one result somehow but I do not have a clue.
so something like
Customer_Id Phone1 Phone2 Phone3
123 123-345-4567 123-345-9987 123-345-2232
Any thoughts would be appreciated.
Question about formatting my query results.
I have a customer table and a customer_phone table linked by customer_id field.
When I select records from customer_phone for a particular customer_id I get as many rows as the customer has phone numbers.
For example
select * from customer_phone where customer_id = 123;
Yeilds
Customer_Id Phone
123 123-345-4567
123 123-345-9987
123 123-345-2232
What I would like is to be able to collapse that to one result somehow but I do not have a clue.
so something like
Customer_Id Phone1 Phone2 Phone3
123 123-345-4567 123-345-9987 123-345-2232
Any thoughts would be appreciated.
RE: Collapsing results to a single row.
could you mention which database system you're using, please?
also, why couldn't you do the crosstab layout (as that's what it's called) in your application language?
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
RE: Collapsing results to a single row.
Using Oracle 10g
Not actually coding, just writing a query to find data so just using pure SQL. Found this link that gives me what I'm looking for.
h
Thanks
RE: Collapsing results to a single row.
Here is the solution...
ht
Sean
RE: Collapsing results to a single row.
nice one
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon