View previous topic :: View next topic |
Author |
Message |
INIYA Beginner
Joined: 02 Mar 2007 Posts: 7 Topics: 4
|
Posted: Thu Apr 19, 2007 6:45 am Post subject: I need the Sql query |
|
|
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 |
|
|
expat Intermediate
Joined: 01 Mar 2007 Posts: 475 Topics: 9 Location: Welsh Wales
|
Posted: Thu Apr 19, 2007 6:52 am Post subject: |
|
|
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 |
|
|
INIYA Beginner
Joined: 02 Mar 2007 Posts: 7 Topics: 4
|
Posted: Thu Apr 19, 2007 7:00 am Post subject: |
|
|
No, I dont have idea, pls advice . |
|
Back to top |
|
|
vkphani Intermediate
Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Thu Apr 19, 2007 7:05 am Post subject: |
|
|
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 |
|
|
INIYA Beginner
Joined: 02 Mar 2007 Posts: 7 Topics: 4
|
Posted: Thu Apr 19, 2007 7:29 am Post subject: |
|
|
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 |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Apr 19, 2007 7:33 am Post subject: |
|
|
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 |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Apr 19, 2007 7:46 am Post subject: |
|
|
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 |
|
|
INIYA Beginner
Joined: 02 Mar 2007 Posts: 7 Topics: 4
|
Posted: Thu Apr 19, 2007 7:58 am Post subject: |
|
|
I don |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Thu Apr 19, 2007 8:24 am Post subject: |
|
|
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Apr 19, 2007 10:28 am Post subject: |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
|
|