Re: Combine multiple records into single row
- From: "--CELKO--" <jcelko212@xxxxxxxxxxxxx>
- Date: 30 Mar 2007 06:22:35 -0700
I can't quite get my mind wrapped around this one. <<
domains:From your example, the three answers seem to be drawn from different
customer_status, department, response
Therefore, you should have seperate columns for them from the start
and get rid of this non-table completely. This thing never made it to
1NF. YOu also semto assume that a table has an ordering, so that
talking about first, second and third anssers makes sense -- it doe
snot.
We can make some wild guesses about using CASE expressions to put your
vague, generic answers into categories, but that is not the real
problem.
SELECT v_id, MAX (CASE WHEN answer IN ('yes', 'no')
THEN answer ELSE NULL END) AS response,
etc.
FROM Foobar
GROUP BY v_id;
The CASE expressions would be converted into CHECK () constriants in
proper DDL.
.
- Follow-Ups:
- Re: Combine multiple records into single row
- From: Matt F
- Re: Combine multiple records into single row
- From: Greg D. Moore \(Strider\)
- Re: Combine multiple records into single row
- References:
- Combine multiple records into single row
- From: franzey
- Combine multiple records into single row
- Prev by Date: Re: Data type in audit record
- Next by Date: Re: Combine multiple records into single row
- Previous by thread: Re: Combine multiple records into single row
- Next by thread: Re: Combine multiple records into single row
- Index(es):
Relevant Pages
|