Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
need sql query - inserting mutilple rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
tilak_arani

New User


Joined: 07 Sep 2006
Posts: 6
Location: chennai

PostPosted: Wed Jul 28, 2010 3:14 pm    Post subject: need sql query - inserting mutilple rows
Reply with quote

This is how my table looks

Fac_id Field_name Value1 value2
1 Name 23 9
1 AGe 23 9
1 income 23 9
2 Name 23 9
2 AGe 23 9
2 income 23 9
3 Name 23 9
3 AGe 23 9
3 income 23 9
4 Name 23 9
4 AGe 23 9
4 income 23 9

Like this thr are some 250 Fac_id's...sequence is missing (1,2,3,4,7,9,...300)

Now my job is to insert a new field_name 'Annuity' for all of the Fac_ids...
the value1 and value2 fields are already defined as '0' and '2' respectively.

I need to write a spufi and not program.

Please assist me in writing the sql-query for the above[list=]
    [/list]
    Back to top
    View user's profile Send private message

    GuyC

    Senior Member


    Joined: 11 Aug 2009
    Posts: 1281
    Location: Belgium

    PostPosted: Wed Jul 28, 2010 4:32 pm    Post subject:
    Reply with quote

    Code:
    insert into table1
    (select fact_id, 'Annuity', '0','2' from table1
    group by fact_id)
    Back to top
    View user's profile Send private message
    tilak_arani

    New User


    Joined: 07 Sep 2006
    Posts: 6
    Location: chennai

    PostPosted: Wed Jul 28, 2010 6:01 pm    Post subject:
    Reply with quote

    Quote:
    it wokred. thanks a lot icon_smile.gif
    Back to top
    View user's profile Send private message
    GuyC

    Senior Member


    Joined: 11 Aug 2009
    Posts: 1281
    Location: Belgium

    PostPosted: Wed Jul 28, 2010 6:10 pm    Post subject:
    Reply with quote

    you're welcome.
    The first one is for free, next time I'll give hints and you have to solve it yourself.
    This is basic SQL so you really should have known this.
    Back to top
    View user's profile Send private message
    View previous topic :: :: View next topic  
    Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
    Page 1 of 1

     

    Search our Forum:

    Similar Topics
    Topic Author Forum Replies Posted
    No new posts reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm
    No new posts query to fetch record which has only ... maxsubrat DB2 12 Mon Dec 11, 2017 5:03 pm
    No new posts Merging 2 records at multiple rows wi... Bijesh DFSORT/ICETOOL 2 Wed Dec 06, 2017 1:50 am
    No new posts Can we combine the rows with same key... V S Amarendra Reddy DB2 12 Fri Dec 01, 2017 10:29 pm
    No new posts How to query MAXGENS of an existing P... Chuchulo Hatyzak JCL & VSAM 4 Wed Nov 22, 2017 10:23 pm

    Facebook
    Back to Top
     
    Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us