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 2000 Forums
 SQL Server Development (2000)
 Ordering books by author

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-18 : 11:55:13
Gareth writes "Dear Sir/Madam

I currently have a books table with the following fields.
Book_ID
Author_Name

When I select from books I want it to select by book_id but the same author can never be subsequent

eg: Roald Dahl 1
John Steinbeck 3
Roald Dahl 2
John Steinbeck 5
Roald Dahl 4

Any ideas how I can do this

Thanks"

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2002-07-18 : 15:46:02
Do you want to ORDER BY authors? Or GROUP BY? You can't Group by authors unless you get some aggregate for Book_ID, which doesn't make much sense.
Your sample has no order- to order by authors say ORDER BY Author after the WHERE clause, or Book_ID.

Sarah Berger MCSD
Go to Top of Page

M.E.
Aged Yak Warrior

539 Posts

Posted - 2002-07-18 : 16:29:41
Only way I can see this happening is with a cursor and a whole loatta unions.

-----------------------
Take my advice, I dare ya

Edited by - M.E. on 07/18/2002 16:30:17
Go to Top of Page
   

- Advertisement -