0

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.

4

1 回答 1

2
select sum(sign(price)*ceiling(abs(price))) as price, item
from product
group by item

如果sumcount使用GROUP BY.

关于错误:这是我第一次在table那里看到关键字。如前所述尝试。

于 2013-09-20T13:53:37.120 回答