Dynamic Column Names

Results 1 to 3 of 3

Thread: Dynamic Column Names

  1. #1
    Join Date
    Dec 1969

    Default Dynamic Column Names

    Okay, this is a weird one. I am using MSSQL. I have 3 tables.<BR><BR>tblTerritories (refers to sales associates)<BR>**************<BR>lngTerritoryID (int) (PK)<BR>strTerritoryID (varchar(4)<BR><BR>tblSubcategories (list of areas that are sold in, ie. WISC, MINN)<BR>****************<BR>lngSubCategoryID (int) (PK)<BR>strSubcategoryName (varchar(25)<BR><BR>tblSalesTaken (holds sales that are takne by sales associate)<BR>**************<BR>lngRowID (int) (PK)<BR>lngTerritoryID (int) (FK)<BR>lngSubCategoryID (int) (FK)<BR>dblSales (money)<BR>dtmDate (DateTime)<BR><BR><BR>Okay, what I need to do is dynamically create a record. I have to show the Territory, and then a seperate column for that Territories sales in each sub category. Example:<BR><BR>Territory --- CO --- IOWA --- MINN --- WISC<BR>N01 500 250 300 600<BR>N02 124 345 150 500<BR>...<BR>...<BR><BR>Please Help.<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Dynamic Column Names

    It&#039;s just a matter of display. Basically, you&#039;re going to need to do something like the Grouping Categories and Subcategories FAQ:<BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=154<BR><BR>Only, you&#039;ll need to keep track of which territory you&#039;re on and when you change territories in your recordset.<BR><BR>And, the display is just a general dump:<BR>http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=171

  3. #3
    Join Date
    Dec 1969

    Default Probably want an OUTER JOIN...

    ...so that all subcategories get *SOME* value for every territory.<BR><BR>Otherwise, if you use an INNER join, the first subcategory might have records for (say) only two territories, so you start by setting up the table with only two territory columns, only to discover when you get to the second subcategory that you need *four* territory columns.<BR><BR>If you use an OUTER join (correctly), then you&#039;ll get all territories. You&#039;ll have NULLs in the spots where there are no sales for a given subcategory in a given territory, but at least the records will exist.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts