Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 group records by two specific fields

Author  Topic 

skippy2727
Starting Member

1 Post

Posted - 2009-11-05 : 04:04:47
I wish to order each record in a subset of a resultset alongside a record in a subset of the same resultset w.r.t two specific fields, i.e age and handle:

time name surname age occupation handle

12:20 Sam Gamgee 27 liontamer grr
12:21 Peter Postlewaite 52 dancer tippytap
12:22 Simon Cowell 98 heckler blech
.
.
.
15:42 Hello Kitty 98 cat blech
15:43 Roger Moore 27 lecherer grr
15:43 Sammy Davis 52 artiste tippytap

I'd like to order them as such:

12:20 Sam Gamgee 27 liontamer grrr
15:43 Roger Moore 27 lecherer grr
12:21 Peter Postlewaite 52 dancer tippytap
15:43 Sammy Davis 52 artiste tippytap
12:22 Simon Cowell 98 heckler blech
15:42 Hello Kitty 98 cat blech

How do I make the select statement to group them as above? have tried using a query in a query, but the syntax is giving me issues...

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-11-05 : 04:37:01
can u post the query and the error message
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-05 : 04:39:18
That is no grouping - it is ordering.

select ...
from ...
order by age,time


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -