3 Years
Discussion Span
Last Post by stpatrck

("SELECT * FROM Quiz WHERE SrNo=counterr") You can't force an undefined variable into the query (typo?). Also, the query will not understand that the counter is a variable but rather expects it to be an internal keyword in SQL. What you may want is ("SELECT * FROM Quiz WHERE SrNo="+counter)...


is 'counterr' in your last statement supposed to be the int counter defined above it? If so...

rs = statement.executeQuery("SELECT * FROM Quiz WHERE SrNo = " + counter + ";");

THanks a lot guys. It worked. This problem is solved I'm very thankful to you.

BUt I've a question how can I print only 3 top score order wise. I mean if 100,99,98 are top scores only they should be displayed the remaining should be skipped. How can I do that?THanks once again.


Try using TOP 'N' in your select statement...

SELECT TOP 3 * ... ORDER BY {scoreColumnName} DESC

This works with MSSQLServer. It may be different depending on the DB Server you are running.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.