473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

select in select and concatenate strings

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
1 5147
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jay Chan | last post by:
I am trying to export data from a SQLServer database into a text file using a stored procedure. I want to be able to read it and debug it easily; therefore, I want all the columns to indent nicely....
4
by: jas | last post by:
I am currently using subprocess to execute a command. Then I read from it's stdout...however, this is hanging on a read..waiting for more bytes. So what I would like is to timeout...and...
3
by: Lars Tackmann | last post by:
Hi - I need a function to concatenate a variable number of strings. I have two ideas but cannot deside which way to go. 1) use the "stdarg" macros - if i use these macros it will be easy to step...
13
by: jt | last post by:
I can't seem to find a way to concatenate strings that have nulls within the string. I have a string that I need another string that has nulls in it and what to append the 2nd string, 3 string...
5
by: Diego Martins | last post by:
Since C++ (and STL) have many ways to do string concatenation, I want to hear (read) from you how you do to concatenate strings with other strings and other types. The approaches I know are: --...
9
by: Dave-o | last post by:
New learner. For the print command and concatenation, the period is difficult for my afflicted eyes to see, but the "+" seems to work. Is this an accepted PHP convention? Thank you, David
6
by: mark83anthony | last post by:
How do I concatenate strings from a column into a single row? Whats the logic to create the function in DB2. Given is below. Color ------ red orange
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.