IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

need sql query - inserting mutilple rows


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
    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
    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
    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 View Bookmarks
    All times are GMT + 6 Hours
    Forum Index -> DB2

     


    Similar Topics
    Topic Forum Replies
    No new posts To get the count of rows for every 1 ... DB2 3
    No new posts RC query -Time column CA Products 3
    No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
    No new posts Dynamically pass table name to a sele... DB2 2
    No new posts Query on edit primary command CLIST & REXX 5
    Search our Forums:

    Back to Top