View previous topic :: View next topic
|
Author |
Message |
barajendran1
New User
Joined: 16 Jun 2010 Posts: 9 Location: Chennai
|
|
|
|
Need a Query for the following :
--------------------------------------
I want to select 3 columns or fields (ID_BRANCH_NUM = 05, ID_BRANCH_NAME = BAL, ID_BRANCH_AREA= CHE) from a table (BRANCH_TABLE).
In the Output DSN.
1.) ID_BRANCH_NUM = 05 must be under the heading BRANCH NUMBER.
2.) ID_BRANCH_NAME = BAL must be under the heading BRANCH NAME.
3.) ID_BRANCH_AREA= CHE must be under the heading BRANCH AREA.
Using AS and each field in the output DSN should be delimited by ';'
Can any one help me with this issue?? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
You would probably have gotten a reply sooner if this had been posted in the DB2 part of the forum rather than this "out of the way" part of the forum
Do do what you want simply specify ';' between the columns in the SELECT statement.
If this does not do what you want, please clarify. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
What have you tried on your own and what results have you gotten? |
|
Back to top |
|
|
barajendran1
New User
Joined: 16 Jun 2010 Posts: 9 Location: Chennai
|
|
|
|
Thanks for your kind replies
Sorry Dick Am new to this forum so I am not sure where to put this post...
Hi Craq, This is the thing which I tried and it works fine for the heading delimited by ';' when I transferred the Output to the Excel Sheet...
SELECT ID_BRANCH_NUM AS "BRANCH NUMBER",';',
ID_BRANCH_NAME AS "BRANCH NAME",';',
ID_BRANCH_AREA AS "BRANCH AREA",';'
FROM BRANCH_TABLE
WHERE ID_BRANCH_NUM = '05'
AND ID_BRANCH_NAME = 'BAL'
AND ID_BRANCH_AREA = 'CHE';
I got the records delimited by ; with the Name changed in the Output DSN.
But When transferred this to the Excel sheet the alignment of the headings is not like that what I want...
The headings were not delimited by ';' , but the records seems finely delimited by ';'.
May I know how to solve this... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
Sorry Dick Am new to this forum so I am not sure where to put this post... |
Not to worry - we'll eventually get it right
Quote: |
The headings were not delimited by ';' |
I'm not where i can test today, but you could try:
Code: |
SELECT ID_BRANCH_NUM AS "BRANCH NUMBER",';' AS ";",
ID_BRANCH_NAME AS "BRANCH NAME",';' AS ";",
ID_BRANCH_AREA AS "BRANCH AREA",';' AS ";" |
|
|
Back to top |
|
|
shanuss
New User
Joined: 16 Jul 2008 Posts: 17 Location: Chennai
|
|
|
|
Even I cannot test it now... But see if this clue helps
SELECT ID_BRANCH_NUM AS "BRANCH NUMBER;",';',
ID_BRANCH_NAME AS "BRANCH NAME;",';',
ID_BRANCH_AREA AS "BRANCH AREA;",';'
FROM BRANCH_TABLE
WHERE ID_BRANCH_NUM = '05'
AND ID_BRANCH_NAME = 'BAL'
AND ID_BRANCH_AREA = 'CHE';
I added ';' to end of column name... Please post if you get a chance to try this. |
|
Back to top |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
These queries relies on the query tool to produce the column headings in the output. If that does not work you could try:
Code: |
SELECT "BRANCH NUMBER;",
"BRANCH NAME;",
"BRANCH AREA;"
FROM SYSIBM.SYSDUMMY
UNION
SELECT ID_BRANCH_NUM,';',
ID_BRANCH_NAME,';',
ID_BRANCH_AREA,';'
FROM BRANCH_TABLE
WHERE ID_BRANCH_NUM = '05'
AND ID_BRANCH_NAME = 'BAL'
AND ID_BRANCH_AREA = 'CHE';
|
|
|
Back to top |
|
|
Ronald Burr
Active User
Joined: 22 Oct 2009 Posts: 293 Location: U.S.A.
|
|
|
|
Perhaps the "problem" lies in the fact that generating just the constant ';' results in a VARCHAR formated output field ( with a binary length field preceding the constant ). This might cause EXCEL to hiccup in determining what columns to put the headings in.
Try ID_BRANCH_NUM AS "BRANCH NUMBER", CHAR(';'), ID_BRANCH_NAME AS "BRANCH NAME", CHAR(';'), etc. and see how that works. |
|
Back to top |
|
|
barajendran1
New User
Joined: 16 Jun 2010 Posts: 9 Location: Chennai
|
|
|
|
Hi All,
I tried the query framed by Dick and it works very fine.
I got the answer exactly what I needed.
Thank U for Dick and everyone. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good to hear it is working - thank you for letting us know
d |
|
Back to top |
|
|
|