title: sum of all drop down values
body: <p>I have a dropdown in my jsp with all users from database. When I select a user I'm able to get the details of the corresponding result, but when I click on all it should give the total individually.  Below is the code that I use to get individually.</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@include file="DBCon.jsp" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;meta charset="utf-8" /&gt;
  
      &lt;link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /&gt;
      &lt;script src="http://code.jquery.com/jquery-1.8.2.js"&gt;&lt;/script&gt;
      &lt;script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="/resources/demos/style.css" /&gt;
      &lt;script&gt;
      $(function() {
          $( "#from" ).datepicker({
              defaultDate: "+1w",
              changeMonth: true,
              numberOfMonths: 3,
              onClose: function( selectedDate ) {
                  $( "#to" ).datepicker( "option", "minDate", selectedDate );
              }
          });
          $( "#to" ).datepicker({
              defaultDate: "+1w",
              changeMonth: true,
              numberOfMonths: 3,
              onClose: function( selectedDate ) {
                  $( "#from" ).datepicker( "option", "maxDate", selectedDate );
              }
          });
      });
      &lt;/script&gt;
  
      &lt;/head&gt; 
      &lt;body&gt;&lt;form name="Reports" method="post" action="DropDown.jsp"&gt;&lt;table&gt;&lt;tr&gt;
  
                       &lt;td&gt;From&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="from" name="from"&gt;&lt;/td&gt;&lt;/tr&gt;
  
                       &lt;tr&gt;&lt;td&gt;To&lt;/td&gt;&lt;td&gt;&lt;input type="text" id="to" name="to"&gt;&lt;/td&gt;&lt;/tr&gt;
                       &lt;tr&gt;&lt;td&gt;Select user:&lt;/td&gt;&lt;td&gt;&lt;select name="user" id="user"&gt;
  
  
              &lt;option value=""&gt;Select User&lt;/option&gt;
              &lt;%
              try{
                  ps=con.prepareStatement("select substr(sys_connect_by_path(userid,','),2) userid from (select rownum rowno,'''' || userid || '''' userid from users where rownum &lt; 4)where connect_by_isleaf = 1 connect by prior rowno = rowno - 1 start with rowno = 1");
                  rs=ps.executeQuery();
                  while(rs.next()){
                %&gt;
                  &lt;option value="&lt;%String user2=rs.getString(1);out.println(user2);%&gt;"&gt;All&lt;/option&gt;
                  &lt;%
              }
              }
              catch(Exception e)
                                         {
                  out.println(e);
              }
              %&gt;
              &lt;%
              try{
                  ps=con.prepareStatement("Select Distinct Specialist from Scope1");
                  rs=ps.executeQuery();
                  while(rs.next()){
                %&gt;
                  &lt;option value="'&lt;%String user1=rs.getString(1);out.print(user1);%&gt;'"&gt;&lt;%out.print(user1);%&gt;&lt;/option&gt;
                  &lt;%
              }
              out.println("&lt;select&gt;");
              }
              catch(Exception e)
                                         {
                  out.println(e);
              }
              %&gt;
  
                               &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
                       &lt;tr&gt;&lt;td&gt;
          Select Type:&lt;/td&gt;&lt;td&gt;&lt;select name="type" id="type"&gt;
              &lt;option value=""&gt;Select Type&lt;/option&gt;
              &lt;option value="'Updates','Multibases','DAIS','Acds','Legis','LegAll'"&gt;All&lt;/option&gt;
              &lt;%
              try{
                  ps=con.prepareStatement("Select Distinct type from Scope1");
                  rs=ps.executeQuery();
                  while(rs.next()){
          %&gt;
                  &lt;option value="'&lt;%String type1=rs.getString(1).trim();out.print(type1);%&gt;'"&gt;&lt;%out.println(type1.trim());%&gt;&lt;/option&gt;
                  &lt;%
              }
              out.println("&lt;Select&gt;");
              }
              catch(Exception e)
                                         {
                  out.println(e);
              }
              %&gt;
                              &lt;/select&gt;&lt;/td&gt;&lt;/tr&gt;
                       &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="Generate" id="sub1" name="sub1"&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;/table&gt; &lt;/form&gt;   &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the get result is as below.</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;%@include file="DBCon.jsp" %&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;&lt;table&gt;
          &lt;%
          String a=request.getParameter("type").trim();
          String b=request.getParameter("user").trim();
          String c=request.getParameter("from").trim();
          String d=request.getParameter("to").trim();
          try{%&gt;
          &lt;tr&gt;&lt;b&gt;&lt;%=b%&gt;&lt;/b&gt;&lt;/tr&gt;&lt;%
              //String sql=("SELECT type, SUM(Update_Count) FROM Scope1 where type in ("+a+") and Specialist in ("+b+") and (RECVD_DATE &gt;='"+c+"' and RECVD_DATE &lt;='"+d+"') group by type");
              //out.print(sql);
              ps1=con.prepareStatement("SELECT type, SUM(Update_Count) FROM Scope1 where type in ("+a+") and Specialist in ("+b+") and (RECVD_DATE &gt;='"+c+"' and RECVD_DATE &lt;='"+d+"') group by type");
              rs1=ps1.executeQuery();
              while(rs1.next())
              {
              %&gt;
  
              &lt;tr&gt;&lt;td&gt;&lt;b&gt;&lt;%=rs1.getString(1)%&gt;&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;%=rs1.getString(2)%&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;%
              }
          }
          catch(Exception e)
          {
              out.println(e);
  }
  %&gt;
     &lt;/table&gt; &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks</p>