1 Reply Latest reply: Dec 19, 2016 9:50 AM by Sunny Talwar RSS

    How to create multiple columns? and then populate them

    Rafael Salero

      My objective is to load data from a table and then create new columns. The problem is that I cannot create the columns on my database because i only have read permissions permissions (and cannot create procedures).

       

      I have a table with columns:

      SELECT id, date_terminated

        FROM otrs.ticket;

       

      What I want is to create a new table with the columns:

      id,

      date_terminated,

      Jan_2014,

      Fev_2014,

      Mar_2014,

      ...,

      Dez_2016 (for now but eventually i´ll have id from 2017, so more columns)

       

      and then fill it with 1 or 0, for each line, if date_terminated < last day of the month

                                                                   then 1 else 0