【发布时间】:2011-01-26 11:26:46
【问题描述】:
我需要一个 sql sign 函数,用于我的 group by 查询来对正数和负数进行分组。
不幸的是 sqlite 不包括一个。
任何人都可以提出解决方法吗?或者如何添加一个与 xcode 中使用的 libsqlite3.dylib 框架一起使用?
我的查询很复杂
select fcid, sum(price), (select sum(price) from tmp b where ((b.due < a.due)
or ((b.due = a.due) and (b.pid <= a.pid)))) as accumulated_price from tmp a
where due >= '2011-01-25' and due < '2011-02-24' and price <> 0 group by fcid
order by due, pid;
我想要做的是sign(price) 上的一个组,所以我得到两个结果和一个负值和一个正值。这些将代表总支出和总收入。
希望添加这些标签(但我不允许创建新标签 libsqlite3.dylib libsqlite3)
【问题讨论】: