sql - Removing Duplicate rows in 1 transaction ID while retaining other transaction item -


i have records :
trans_id item_name total_trans
101                                           5
101                                           5
101                  b                          5
101                  c                          5
101                  b                          5
102                                           3
102                  c                          3
102                  c                          3

etc (aprox 270k record)

what query should use make :

trans_id item_name    value  total_trans
101                                   2/5                  5
101                  b                  2/5                  5
101                  c                  1/5                  5
102                                   1/3                  3
102                  c                  2/3                  3

thank much

try this

select  `trans_id`,  `item_name`,  concat(count(*), '/', `total_trans`) value,  `total_trans`  mytable  group `item_name`, `trans_id`, `total_trans` 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -