Re: Combine multiple records into single row



I can't quite get my mind wrapped around this one. <<

From your example, the three answers seem to be drawn from different
domains:

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.

.



Relevant Pages

  • Re: Combine multiple records into single row
    ... customer_status, department, response ... you should have seperate columns for them from the start ... and get rid of this non-table completely. ... Greg Moore ...
    (comp.databases.ms-sqlserver)
  • intensity #prep territorial yarn
    ... She wants to renew leading expressions ... and protests in response to the spring. ... Ahmad plots the departure in response to hers and ...
    (sci.crypt)
  • Re: Query problem
    ... QID, RID, Response ... 1, 1, Truck ... Then I would Group By RID & Response to find those with a Countequal ...
    (microsoft.public.access.queries)
  • Re: Large Zip files in Internet Logs folder...
    ... I actually meant that there is a good chance that you could safely get ... rid of both the files _and_ ZA. ... Thanks again so much for your response to my last query. ... have layed out a logical and easy to understand approach to the firewall ...
    (comp.security.firewalls)
  • Re: Oh, for the good old days...
    ... bomb US embassies and have an aspirin factory bombed in response. ... doesn't anticipate how his expressions will impact others. ... "The American Way of Life is heading for extinction." ...
    (alt.politics.bush)