Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 1278
    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: 1278
    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 Join in SQL Query vickey_dw DB2 0 Tue Jan 17, 2017 12:15 am
    This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
    No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
    No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
    This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


    Facebook
    Back to Top
     
    Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us