MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

I need the Sql query

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
INIYA
Beginner


Joined: 02 Mar 2007
Posts: 7
Topics: 4

PostPosted: Thu Apr 19, 2007 6:45 am    Post subject: I need the Sql query Reply with quote

Pls find the below tables

table a

Code:

account(9)      Roll-up-account(9)             

a00000000     x00000000
b00000000     x00000000
c00000000     x00000000
d00000000     x00000000
e00000000     y00000000
g00000000     y00000000
tybghg000     zx00000000
sdfdsfdfdf    sfdsfwdfddf
sgfsdfgsfd    sgsgfdgfgfg


Table b
Code:

Roll-up-account

x00000000
y00000000
zx00000000


Table C

Code:


Ntrl-id(Pkey)                     Account(9)

1xxxxxxxxxccf                    a00000000   
2xxxxxxxxxvvf                    b00000000
dfdfffffffffffffffff             dfdafdfdfdf
454xxxxxxxvvd                    c00000000   
56xxxxxxxxxvd                    d00000000   
343xxxxxxxxxv                    e00000000   
4343xxxxxxxxv                    g00000000 
3434xxxxxxxxv                    tybghg000   
3445xxxxxxxxx                    x00000000
4123xxxxxxxxx                    y00000000
1431xxxxxxxxx                    zx00000000
sdfdsfdsfdfdfdfd                 dfdfdsfdsfdsf
343ererer34ere                   rertewrewre
fgefretre343243                  wrterereree


i want the output like as follows

Code:

NTRL_ID                              Account

1xxxxxxxxxccf                    a00000000   
2xxxxxxxxxvvf                    b00000000
454xxxxxxxvvd                    c00000000   
56xxxxxxxxxvd                    d00000000   
343xxxxxxxxxv                    e00000000   
4343xxxxxxxxv                    g00000000 
3434xxxxxxxxv                    tybghg000   
3445xxxxxxxxx                    x00000000
4123xxxxxxxxx                    y00000000
1431xxxxxxxxx                    zx0000000



Note: Table C had lot of accounts , I want only the account from Table A and B
My req is , want to fetch the roll_up_account from table B and fetch the corresponding roll-up-account and account from table A
and fetch the NTRL_id from table C.
Back to top
View user's profile Send private message
expat
Intermediate


Joined: 01 Mar 2007
Posts: 475
Topics: 9
Location: Welsh Wales

PostPosted: Thu Apr 19, 2007 6:52 am    Post subject: Reply with quote

What have you tried already, and what were the results ?
_________________
If it's true that we are here to help others,
then what exactly are the others here for ?
Back to top
View user's profile Send private message
INIYA
Beginner


Joined: 02 Mar 2007
Posts: 7
Topics: 4

PostPosted: Thu Apr 19, 2007 7:00 am    Post subject: Reply with quote

No, I dont have idea, pls advice .
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Thu Apr 19, 2007 7:05 am    Post subject: Reply with quote

Iniya,

Try this.

Code:
select a.roll_up_account, a.account, c.NTRL_id from table a, c where b.roll_up_account = a.roll_up_account and c.account = a.account
Back to top
View user's profile Send private message Send e-mail
INIYA
Beginner


Joined: 02 Mar 2007
Posts: 7
Topics: 4

PostPosted: Thu Apr 19, 2007 7:29 am    Post subject: Reply with quote

Table A



Code:


account(9)      Roll-up-account(9)

a00000000        x00000000
b00000000        x00000000
c00000000        x00000000
d00000000        x00000000
e00000000        y00000000
g00000000        y00000000
tybghg000        zx00000000
sdfdsfdfdf         sfdsfwdfddf
sgfsdfgsfd         gsgfdgfgfg


Table B


Code:


Roll-up-account  Updt_dt

x00000000        2007-04-19
y00000000        2007-04-19
zx0000000        2007-04-19
dfdasfdsfd         2007-04-18
dfgstrtrtrg         2007-04-17

Table C


Code:


Ntrl-id(Pkey)                Account(9)

1xxxxxxxxxccf           a00000000
2xxxxxxxxxvvf           b00000000
dfdfffffffffffffffff           dfdafdfdfdf
454xxxxxxxvvd          c00000000
56xxxxxxxxxvd          d00000000
343xxxxxxxxxv          e00000000
4343xxxxxxxxv          g00000000
3434xxxxxxxxv         tybghg000
3445xxxxxxxxx         x00000000
4123xxxxxxxxx          y00000000
1431xxxxxxxxx          zx00000000
sdfdsfdsfdfdfdfd         dfdfdsfdsfdsf
343ererer34ere          rertewrewre
fgefretre343243         wrterereree


OUTPUT result will be

Code:


NTRL_ID              Account

1xxxxxxxxxccf        a00000000
2xxxxxxxxxvvf        b00000000
454xxxxxxxvvd       c00000000
56xxxxxxxxxvd       d00000000
343xxxxxxxxxv       e00000000
4343xxxxxxxxv       g00000000
3434xxxxxxxxv       tybghg000
3445xxxxxxxxx       x00000000
4123xxxxxxxxx        y00000000
1431xxxxxxxxx        zx00000000



1 . I want to fetch the roll-up-account from tabel B whcih fall under updt_dt as cuerrent day(2007-04-19)
2. Fetch the account from Tbale A using the Roll-up-account
3. Fetch the Ntrl_id from Table C for both roll-up-account and account
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Apr 19, 2007 7:33 am    Post subject: Reply with quote

use 'preview' before submitting your posts then you would see that your tags are wrong.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Apr 19, 2007 7:46 am    Post subject: Reply with quote

that is reasonably similar to your previous request so the code is going to be reasonably similar. If you know SQL you should be able to work it out. If you do not - why are you doing this?
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
INIYA
Beginner


Joined: 02 Mar 2007
Posts: 7
Topics: 4

PostPosted: Thu Apr 19, 2007 7:58 am    Post subject: Reply with quote

I don
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Thu Apr 19, 2007 8:24 am    Post subject: Reply with quote

if you do not know SQL why are you doing this?

vkphani's post DID satisfy your request. You have now gone and changed the request. It is reasonably simple SQL you can play on SPUFI until you adapt his post to get what you want.
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12366
Topics: 75
Location: San Jose

PostPosted: Thu Apr 19, 2007 10:28 am    Post subject: Reply with quote

INIYA,

Do you know the difference between "Please help me" vs "I Need the sql" ? Learn about the difference first and then post in the forums.

Thanks

Kolusu
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group