iphone - Xcode,iPhone,Sqlite是否需要用于分组的签名功能?

标签 iphone xcode sqlite

我需要通过查询将sql sign函数用于我的组,以对正数和负数进行分组。

不幸的是,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)

最佳答案

不知道这是否是您的最佳选择,但是您可以尝试:

select your_val > 0, sum(aggregated_value)
  from your_table
 group by your_val > 0;


这样,您应将0设置为零或负值,将1设置为正值。

更新:如果fcid是您需要签名的字段,则可以尝试:

select fcid > 0, 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 > 0;


请注意,您的order by子句是无用的,因为无论如何您都要对结果进行分组。

关于iphone - Xcode,iPhone,Sqlite是否需要用于分组的签名功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4796688/

相关文章:

java - E/SQLite数据库 : Error inserting with SQLiteConstraintException

iphone - 如何将制表位添加到 NSAttributedString 并显示在 UITextView 中

iPhone 配置文件续订帮助

iphone - iPhone 版 UnRar 库 - 受密码保护的 Rar 文件

iphone - 使用导航栏在 IB 中设计 View ?

ios - 仅在 Testflight 上崩溃

C++ Xcode 断言在发布中评估

mysql - 如何将所有现有应用程序数据从 sqlite3 复制到 Rails 中的 MySQL?

xcode - 使用外部 Xcode Clang 静态分析器二进制文件,并进行额外检查

.net - 如何在 Visual Studio 2008 中从现有 SQLite 数据库创建 Entity Framework 模型?