What is wrong in this SQL code?

  • Thread starter Thread starter Miguel Dias Moura
  • Start date Start date
M

Miguel Dias Moura

Hello,

i have this code to order the 3 authors that appear more often in a book
database:

SELECT Author, COUNT(Author) AS totalBooks
FROM Books
GROUP BY Author
ORDER BY totalBooks DESC

When i added the line "ORDER BY totalBooks DESC" i got the error:
System.Data.OleDb.OleDbException: No value given for one or more required
parameters.

Without this line it works ok but it's not sorted as i want.

Can you tell me what is going on?

Thank You,
Miguel
 
Try

ORDER BY COUNT(Author)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Try this

SELECT Author, COUNT(Author) AS totalBooks
FROM Books
GROUP BY Author
ORDER BY COUNT(Author) DESC

Carlos Barini
MCP, MCSA, MCSE, MCDBA
 
Thanks,

i just made it work.

Cheers,
Miguel

Carlos Barini said:
Try this

SELECT Author, COUNT(Author) AS totalBooks
FROM Books
GROUP BY Author
ORDER BY COUNT(Author) DESC

Carlos Barini
MCP, MCSA, MCSE, MCDBA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top