Reputation: 13676
Hi I have a table with item and price as shown below
item price
ABC 5.0
DEF 6.0
and I am trying to execute it with the following query.
select sum(sign(price)*ceiling(abs(price))) as price, item from product
Now when I execute this query staight away in the following way it works shows total as 11.0 in output for both item
statement.exectuteQuery("select sum(sign(price)*ceiling(abs(price))) as price, item from product")
But when I put query in string strangely it does not work and it gives null as output in price column
String qry = "select sum(sign(price)*ceiling(abs(price))) as price, item from product";
statement.exectuteQuery(qry);
Please guide. Thanks in advance.
Upvotes: 0
Views: 877
Reputation: 109567
select sum(sign(price)*ceiling(abs(price))) as price, item
from product
group by item
The aggregate functions such as sum
and count
will do the entire table, if not using a GROUP BY
.
Concerning the error: it is the first time I see the keyword table
there. Try it as mentioned.
Upvotes: 2