isnull function to combine records into 1 row
Posted on 2007-11-17
Hi, I have a table that has the person, company and customer number. Thereare more than one rows for each customer. I want one row, with the corresponding company customer number. I performed a case statement, but am still getting back more than one row.
Customer Company CompanyID
1. Mouse, Mickey CompanyA CompanyA_ID
2. Mouse, Mickey CompanyB CompanyB_ID
I want Mouse, Mickey, CompanyA_ID CompanyB_ID
SELECT Customer, CASE Company WHEN ComapnyA THEN CompanyA_ID END CompanyA_ID,
CASE Company WHEN CompanyB THEN CompanyB_ID END CompanyB_ID
My result looks like this:
Mouse, Mickey NULL HI201
Mouse, Mickey CB747 NULL
How can I group this to end up with one row?
I want Mouse, Mickey CB747 H1201