我想从DB获取数据到jtable。我不是用正常的方式问。这意味着我向数据库发送一些数据。这样想。通过发票,我向 Db 发送了很多数据。一天结束时,我想搜索商品销售。认为一个名为“apple”的促销商品售出了 4 次。
0.item item code qty
1.apple 20 5
2.apple 20 20
3.apple 20 23
4.apple 20 7
它们在数据库中。但我只想要
0.item item code qty
1.apple 20 55
当天促销商品摘要。
最佳答案
基本上,您应该能够使用 SQL 语句来完成此操作,例如...
select item, item_code, sum(qty) as qty from item_table_name where item = 'apple`
(ps-自从我写 SQL 以来已经很长时间了;))
您真正需要的是某种好的 SQL 教程。尝试看一下 SQL Tutorial和 SQLCourse
正如伯利熊所建议的
Rather than
item = 'apple'
you wantgroup by 'item code'
since all the items have different names
当然,这是假设您想要总结每个项目组,但仍然值得注意
关于java - 我怎样才能像这样从数据库获取数据到jtable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20727456/