Reply to Re: Combine multiple records into single row

Your name:

Reply:


Posted by --CELKO-- on 03/30/07 13:22

>> 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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация