|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Data pivot problem (brain isn't working right today)
Hi all,DURETTE, STEVEN J (ATTASIAIT) 03/10/10 03:14 P Syntax not exact, but this is the process.Maureen 03/10/10 06:46 P Hi all, Got a problem trying to convert a many to many relationship to a grid. There are three tables (defined below), and I need the output in a certain way (also defined below). I've done this before, but for the life of me I can't remember how. Table 1 (Target_Stratifications): Stratification varchar(100) not null primary key Strat_owner varchar(100) not null Table 2 (Target_Types): Target_type varchar(15) not null primary key Target_default numeric(9, 4) not null default 0 Target_Tolerance numeric(9, 4) not null default 0 Table 3 (Target_Targets): Stratification varchar(100) not null Target_type varchar(15) not null Target numeric(9, 4) not null default 0 *Primary Key (stratification, target_type) * [Stratification] References Target_Stratifications.stratification [on update cascade, on delete cascade] * [target_type] References Target_Types.target_type [on update cascade, on delete cascade] It's a pretty normalized set of tables. In stratifications is a list of proper names, and in target types is the Proper name for the target of the measure that is being worked on along with default values and tolerances. I need to get the data in this format (| used just to separate the columns, the actual result will be put in a cfgrid): Stratification|Target_Type(1)|Target_Type(2)|Target_Type(3)|Target_Type( 4)|...|Target_Type(n) Steve|100|50|25|10|...|15 Mike|25|75|2|100|...|75 Can someone push me in the right direction? Thanks, Steve Syntax not exact, but this is the process. <cfquery name="getStrats> Select Stratification from Target_Stratifications </cfquery> <cfquery name="getTargets"> Select Target_Type from Target_Types </cfquery> <table> <!--- Set headings ---> <tr> <td>Name</td> <cfloop query = "getTargets"> <td>#Target_Type#</td> </cfloop> </tr> <!--- Do Table ---> <cfloop query = "getStrats"> <tr> <td>#Stratification#</td> <cfloop query = "getTarget"> <cfquery name= "getTargetTargets"> select * from Target_Targets where Stratification = getStrats.Stratification and Target_type = getTargets.Target_type </cfquery> <td>#getTargetTargets.Target#</td> </cfloop> </tr> </cfloop> </table> ----- Excess quoted text cut - see Original Post for more -----
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||