我需要在分组的表格上显示值。目前我通过两个 SQL 脚本手动完成。
除了将这些脚本应用到我的 dao 中,我可以通过某种方式在客户端进行吗?
表格内容看起来像这样
fruit name, fruit bought, fruit sold
apple, 1, 0
apple, 0, 1
orange, 1, 0
orange, 1, 0
html 表上的预期结果将是。
Fruit name - Fruit bought - Fruits not bought
apples - 9 - 20
oranges - 10 - 10
我目前正在使用 jQuery 和数据表。
最佳答案
开始时在数据库级别执行此操作会更容易:
SELECT fruitname, SUM(fruit_bought), SUM(fruit_sold)
FROM table
GROUP BY fruitname
ORDER BY fruitname
当然,您需要从某个地方获取原始库存水平来计算您的“未售出”值(value),但此查询将为您提供购买/销售值(value)的总和。
关于java - jQuery 数据表分组返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4824890/