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: 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 compare 2 rows within the same file ram_vizag SYNCSORT 7 Wed Jun 14, 2017 12:34 am
    No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
    No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
    No new posts To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
    No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm


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