0

I want group this table

column1|    date

A      |2016-07-01
A      |2016-07-01
A      |2016-07-02
C      |2016-07-01
C      |2016-07-02

and i need get the result something like this

column1 |   date
A       |2016-07-01
A       |2016-07-02
C       |2016-07-01
C       |2016-07-02

This is what i did to sort the table to get the result like above table

SELECT * FROM table1 GROUP BY column1 and date

but not working . How can i do that ?

ARUN Madathil
  • 896
  • 10
  • 16
  • 1
    You've seen the other threads on this topic? http://stackoverflow.com/questions/2421388/using-group-by-on-multiple-columns – chris85 Jul 09 '16 at 18:52

2 Answers2

1

Based on your desired results ... It appears that you are looking to get all distinct combinations of two columns

There are 2 ways to do that :

  1. select distinct column1, date from table1

  2. select column1, date from table1 group by column1, date

objectNotFound
  • 1,683
  • 2
  • 18
  • 25
1

For the result show in your question you should use

SELECT column1, `date`  FROM table1 GROUP BY  `date`
order by column1, `date`
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107