By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,590 Members | 2,191 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,590 IT Pros & Developers. It's quick & easy.

select in select and concatenate strings

P: n/a
Hello!

I have got:

SELECT char(week_iso(current date)) FROM sysibm.sysdummy1
+------------+
| 00001 |
+------------+
| 45 |
+------------+

This is number of the week now,
And I have got table PROGN:

Select * from PROGN where id= 10714
+----------+----------+----------+----------+----------+----------+
| PRO144 | PRO145 | PRO146 | PRO147 | PRO148 | PRO149 |
+----------+----------+----------+----------+----------+----------+
| 50 | 55 | 56 | 36 | 33 | 33 |
+----------+----------+----------+----------+----------+----------+

where in name PRO1xx -xx are number of the week
And now I must do something like this:
select ID, PRO1[number of the week] from PROGN where id=
10714)
or maybe better look:
select ID, PRO1xx from PROGN where id= 10714),

where xx=SELECT char(week_iso(current date)) FROM
sysibm.sysdummy1

I try this, but no results....

select ID, 'PRO1'||(SELECT char(week_iso(current date)) FROM
sysibm.sysdummy1)

from PROGN where id= 10714)

Thanks for help.

Nov 7 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
kr******@gmail.com wrote:
Hello!

I have got:

SELECT char(week_iso(current date)) FROM sysibm.sysdummy1
+------------+
| 00001 |
+------------+
| 45 |
+------------+

This is number of the week now,
And I have got table PROGN:

Select * from PROGN where id= 10714
+----------+----------+----------+----------+----------+----------+
| PRO144 | PRO145 | PRO146 | PRO147 | PRO148 | PRO149 |
+----------+----------+----------+----------+----------+----------+
| 50 | 55 | 56 | 36 | 33 | 33 |
+----------+----------+----------+----------+----------+----------+

where in name PRO1xx -xx are number of the week
And now I must do something like this:
select ID, PRO1[number of the week] from PROGN where id=
10714)
or maybe better look:
select ID, PRO1xx from PROGN where id= 10714),

where xx=SELECT char(week_iso(current date)) FROM
sysibm.sysdummy1

I try this, but no results....

select ID, 'PRO1'||(SELECT char(week_iso(current date)) FROM
sysibm.sysdummy1)

from PROGN where id= 10714)
You have a bad table design...having said that you will need to undo the
bad by pivoting the table, so you can get back into the relational world.

Google for "SQL on Fire". There are PIVOT and UNPIVOT examples.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Nov 7 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.