how to choose which row to insert with same id in sql?

Posted by user1429595 on Stack Overflow See other posts from Stack Overflow or by user1429595
Published on 2012-05-31T23:31:28Z Indexed on 2012/06/02 22:40 UTC
Read the original article Hit count: 181

Filed under:
|
|

so Basically I have a table called "table_1" :

ID   Index          STATUS          TIME        DESCRIPTION
1     15          pending           1:00       Started Pending
1     16          pending           1:05       still in request
1     17          pending           1:10       still in request
1     18          complete          1:20       Transaction has been completed
2     19          pending           2:25       request has been started
2     20          pending           2:30       in progress
2     21          pending           2:35       in progess still
2     22          pending           2:40       still pending
2     23          complete          2:45       Transaction Compeleted

I need to insert these data into my second table "table_2" where only start and compelete times are included, so my "table_2" should like this:

ID   Index   STATUS          TIME          DESCRIPTION
1     15     pending         1:00          Started Pending
1     18     complete        1:20          Transaction has been completed
2     19     pending         2:25          request has been started
2     23     complete        2:45          Transaction Compeleted

if anyone can help me write sql query for this I would highly appreciate it. Thanks in advance

© Stack Overflow or respective owner

Related posts about sql

Related posts about query