#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Question Selecting many adjacent columns easily


    I need to add many columns together. Here is an example -
    SELECT DISTINCT
    a.st, (sum_cat1+sum_cat2+sum_cat3+sum_cat4+sum_cat5+sum_cat6+sum_cat7+sum_cat8+sum_cat9+sum_cat10+sum_cat1 1+sum_cat12+sum_cat13+sum_cat14+sum_cat15+sum_cat16+sum_cat17+sum_cat18+sum_cat19+sum_cat20+sum_cat2 1+sum_cat23+sum_cat24+sum_cat25+sum_cat26)/sum_unity
    FROM
    reportwe_gamesa.gsa_cats_table a

    I'm used to a statistical program SPSS where I can do the following-
    sum_cat1 TO sum_cat26
    if the columns are adjacent to each other.
    Is there a way to do this in MySql?
    Thanks in advance.
    Mark
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,120
    Rep Power
    4274
    Originally Posted by bbewkram
    Is there a way to do this in MySql?
    nope
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo