Generating crosstab-like tables dynamically

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: John Hoge (jhoge123_at_yahoo.com)
Date: 11/30/04


Date: 30 Nov 2004 10:24:19 -0800

I'm working on a product comparison site that has a table listing all
attributes of all products in this layout:

Create Table ProdAtt(
 Product varchar(50),
 AttributeID int not null references Attributes,
 AttVal varchar(255)
)

This schema is used so that DML is not required to add new attributes
- No table columns need to be added if a site admin wants to add a new
product feature, say heated seats. They just add a new entry to the
attribute table and then add rows to the ProdAtt table to record which
cars have this feature.

The data looks like this:

FORD COLOR BLUE
FORD TRANSMISSION AUTOMATIC
CHEVY COLOR RED
CHEVY TRANSMISSION MANUAL
....

Say the visitor wants to see a comparison between Ford and Chevy. I
would like to use an .net DataGrid to display the data, so it would be
great to have a table like this:

Product Ford Chevy
Transmission Automatic Standard
Color Blue Red

Before .net I would just manually build an html table from the
normalized data as it came out of the database table, but the this
technique would miss out on the presentation layer nicities of the
DataGrid control such as paging and sorting.

It seems like a fairly common problem, so there must be a best
practice for transforming a table this way. Any guess?



Relevant Pages

  • Re: House bigs spending tax bucks on autos: Rangel spent $777 a month for lease on Cadillac
    ... who doled out $147 a month for a Chevy Impala. ... legally use their office budgets to lease vehicles. ... he once tooled around in a Ford Escape hybrid. ... _Leonard Boswell, $6,298.56, D-Iowa, Chrysler Town & Country ...
    (soc.retirement)
  • Re: Ford or Chevy?
    ... For the rest of the group it's still Ford or Chevy? ... John, who really does reprogram a few selected GM PCMs, the 8051 being ... That's the last pre-OBD-2 'Vette/9C1 PCM. ...
    (rec.outdoors.rv-travel)
  • Re: AMD 64/PCI-Express and powerful system...
    ... Ford or Chevy) will not be obsolete in two or three months as the chip will. ... the AMD 64 is rather like a new technology automotive ... engine that will be the fastest engine in the world -- someday, ...
    (microsoft.public.windowsxp.hardware)
  • Re: Chevrolet Speedometer Stuck
    ... > Nate wrote: ... >> knowledge, Ford, Chevy and Dodge all have that in their computers. ... > reset and nothing else had changed. ...
    (rec.outdoors.rv-travel)
  • Re: Count Unique Items with Multiple Criteria
    ... I added the VLOOKUP function to get the results ... Ford xjd-394 1 ... Chevy gwg-394 2 ... Toyota skd-333 4 ...
    (microsoft.public.excel)