Swee
Swee

Reputation: 13

MYSQL Merge rows based on occurence

I have the following table:

empid,paygrp,paycode,amount
1      A       1       200
1      A       2       300
1      A       3       500
1      B       4       600
1      B       5       700

is it possible to use sql statement to produce the following result?

1      A       1       200         B       4      600
1      A       2       300         B       5      700
1      A       3       500

Upvotes: 1

Views: 92

Answers (1)

Jonathan Hall
Jonathan Hall

Reputation: 79794

You need to do two queries for this:

SELECT *
FROM table
WHERE paygrp='A';

SELECT *
FROM table
WHERE paygrp='B';

Upvotes: 1

Related Questions