5 Replies - 2281 Views - Last Post: 23 July 2011 - 09:24 PM

#1 Student7574  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-July 11

How to use sum sql and display it in jsp page

Posted 10 July 2011 - 01:26 AM

I know how to use sum sql, but i dont know how to display it result in jsp page.
For example, my table database like this:

TableName: user
|userid|name|salary|
|1000 |john|500 |
|1001 |joe |600 |
|1002 |jim |700 |

so my sql statement like this, SELECT SUM(salary) FROM user WHERE userid=1000,1001. So the result
is 1100.

So the problem is, how i can display the result in jsp page..Someone help me please..

Is This A Good Question/Topic? 0
  • +

Replies To: How to use sum sql and display it in jsp page

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3576
  • View blog
  • Posts: 10,439
  • Joined: 08-June 10

Re: How to use sum sql and display it in jsp page

Posted 10 July 2011 - 04:07 AM

I assume your SQL query would fail (or not output what you expect), the WHERE clause is odd.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6106
  • View blog
  • Posts: 23,653
  • Joined: 23-August 08

Re: How to use sum sql and display it in jsp page

Posted 10 July 2011 - 04:43 AM

Moved to JavaEE
Was This Post Helpful? 0
  • +
  • -

#4 Student7574  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-July 11

Re: How to use sum sql and display it in jsp page

Posted 10 July 2011 - 11:23 PM

View PostDormilich, on 10 July 2011 - 04:07 AM, said:

I assume your SQL query would fail (or not output what you expect), the WHERE clause is odd.

what is the correct statment if i want to get the result?
Was This Post Helpful? 0
  • +
  • -

#5 shadowBean  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 46
  • Joined: 14-June 08

Re: How to use sum sql and display it in jsp page

Posted 19 July 2011 - 08:14 PM

View PostStudent7574, on 10 July 2011 - 11:23 PM, said:

View PostDormilich, on 10 July 2011 - 04:07 AM, said:

I assume your SQL query would fail (or not output what you expect), the WHERE clause is odd.

what is the correct statment if i want to get the result?


SELECT SUM(salary) FROM user WHERE userid IN (1000,1001);


When you get the result you have to name the column as
new String(rs.getString("SUM(salary)").getBytes("utf8"), "UTF-8");

Was This Post Helpful? 0
  • +
  • -

#6 Student7574  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 09-July 11

Re: How to use sum sql and display it in jsp page

Posted 23 July 2011 - 09:24 PM

Its work. thanks shadowBean :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1