sql - Get the aggregate column values in JSP when using group-by -
i have problem when retrieving data sql using jsp.
resultset rs = statement.executequery("select orderdate, sum(orderingcost) `shopping`.`order` group orderdate"); int count = 0; //string while (rs.next()) { //string orderdate = rs.getstring("orderdate"); //string orderingcost = rs.getstring("orderingcost"); system.out.println(count); count++; }
i use group statement group data.
however, don't know how data out when group applied.
can me?
you need alias column:
select orderdate, sum(orderingcost) orderingcost `shopping`.`order` group orderdate
then you'll have column named orderingcost
in resultset, , can do:
double orderingcost = rs.getfloat("orderingcost") // need getfloat instead of string since it's numeric value
Comments
Post a Comment