I need the Sql query
Select messages from
# through # FAQ
[/[Print]\]

MVSFORUMS.com -> Database

#1: I need the Sql query Author: INIYA PostPosted: Thu Apr 19, 2007 6:45 am
    —
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.

#2:  Author: expatLocation: Welsh Wales PostPosted: Thu Apr 19, 2007 6:52 am
    —
What have you tried already, and what were the results ?

#3:  Author: INIYA PostPosted: Thu Apr 19, 2007 7:00 am
    —
No, I dont have idea, pls advice .

#4:  Author: vkphani PostPosted: Thu Apr 19, 2007 7:05 am
    —
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

#5:  Author: INIYA PostPosted: Thu Apr 19, 2007 7:29 am
    —
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

#6:  Author: Nic CloustonLocation: At Home PostPosted: Thu Apr 19, 2007 7:33 am
    —
use 'preview' before submitting your posts then you would see that your tags are wrong.

#7:  Author: Nic CloustonLocation: At Home PostPosted: Thu Apr 19, 2007 7:46 am
    —
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?

#8:  Author: INIYA PostPosted: Thu Apr 19, 2007 7:58 am
    —
I don

#9:  Author: Nic CloustonLocation: At Home PostPosted: Thu Apr 19, 2007 8:24 am
    —
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.

#10:  Author: kolusuLocation: San Jose PostPosted: Thu Apr 19, 2007 10:28 am
    —
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



MVSFORUMS.com -> Database


output generated using printer-friendly topic mod. All times are GMT - 5 Hours

Page 1 of 1

Powered by phpBB © 2001, 2005 phpBB Group