What is wrong in this SQL code?

  • Thread starter Miguel Dias Moura
  • 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
 
K

Kevin Spencer

Try

ORDER BY COUNT(Author)

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

Carlos Barini

Try this

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

Carlos Barini
MCP, MCSA, MCSE, MCDBA
 
M

Miguel Dias Moura

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

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top