Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2011

    Question Unanswered: DB2 syscolumn join to a user table

    I'm looking for a solution to writing a query to join to the syscolumn table and perform a 'minimum' function on all columns in a certain table.

    I've started with something like this but am not getting the results I'm looking for.

    select min('+colname+') from demand_table, sysibm.syscolumns
    where '+colname+' = name
    and tbname = 'DEMAND_TABLE'

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    I do not think you can do what you want in a single step. You need to generate the SQL you want then execute that SQL.

    select 'select min('||colname||') from demand_table' from syscat.columns where tabname = 'DEMAND_TABLE'

Posting Permissions

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