Skip to main content
Inspiring
December 16, 2007
Question

SQL grouping

  • December 16, 2007
  • 11 replies
  • 470 views
I have a table that has data like this:

EVENT - DATE
meeting - 12/1/07
party - 12/4/07
meeting - 12/9/07

I want to query the table and return all items by event type, sorted by
date.

So, the above should return:

meeting - 12/1/07
meeting - 12/9/07
party - 12/4/07

How can I do that? I'm using TSQL and thought the group by clause is what I
need, but that gives me all sorts of errors unless I include every SELECT
column in my GROUP BY statement, which seems odd and messy.

Am I missing something obvious?

-Darrel


This topic has been closed for replies.

11 replies

Inspiring
December 16, 2007
.oO(Darrel)

>I have a table that has data like this:
>
>EVENT - DATE
>meeting - 12/1/07
>party - 12/4/07
>meeting - 12/9/07
>
>I want to query the table and return all items by event type, sorted by
>date.
>
>So, the above should return:
>
>meeting - 12/1/07
>meeting - 12/9/07
>party - 12/4/07
>
>How can I do that?

Maybe I'm missing something, but what about a simple

ORDER BY type, date

?

Micha