0

How can I query merge rows which has same dates and get rid of null

Date       | Long | Short
2006-07-06 | t1   |
2006-07-06 |      | t2
2006-07-05 | t1   | 
2006-07-05 |      | t2
2006-07-04 | t1   |
2006-07-04 |      | t2
2006-07-03 | t1   | 
2006-07-03 |      | t2

to this

Date       | Long | Short
2006-07-06 | t1   | t2
2006-07-05 | t1   | t2
2006-07-04 | t1   | t2
2006-07-03 | t1   | t2
fthiella
  • 48,073
  • 15
  • 90
  • 106
user2115506
  • 23
  • 1
  • 6

2 Answers2

0

One approach to getting the specified resultset, is using a GROUP BY and aggregate functions:

SELECT t.Date
     , MAX(t.Long) AS `Long`
     , MAX(t.Short) AS `Short`
  FROM mytable t
 GROUP
    BY t.Date
spencer7593
  • 106,611
  • 15
  • 112
  • 140
-1
SELECT `date`, MAX(`long`) `long`, MAX(short) short
FROM yourtable
GROUP BY `date`
fthiella
  • 48,073
  • 15
  • 90
  • 106
  • Sorry for taking long to get back, i just finished and it was the weekend, Thank you for the help it worked, thanks again – user2115506 Jul 15 '13 at 12:12