1

我有一个带列的表;

  • 全名,
  • 组号,
  • 日期,
  • 日程,
  • 克拉蒙,
  • 德拉蒙,
  • 金额。

我想选择那些 textbox111.text 大于 formula 的列SUM(Cramount)*26/(SUM(Dramount+Iamount))

下面的 SQL 给了我语法错误,有人可以帮助我吗 DATABASE IS SQLITE AND PROGRAMMING IN XOJO。

 sql= "SELECT Fullname, GroupNo, Tdate, Schedule,( SUM(Cramount)*26)/SUM(Dramount+Iamount) AS ok FROM Trans WHERE Branchcode = '1210 - Loans'GROUP BY LoanID  HAVING SUM(Cramount)*26/(SUM(Dramount+Iamount)) < '"TextBox111.text'""
4

1 回答 1

1

您的 SQL 字符串存在一些问题,您在 TextBox111.text 之后的单引号和双引号以错误的方式出现,并且您需要将该控制值与“+”连接起来,因为 Xojo 不进行字符串插值。

尝试类似:

sql= "SELECT Fullname, GroupNo, Tdate, Schedule, (SUM(Cramount)*26)/SUM(Dramount+Iamount) AS ok FROM Trans WHERE Branchcode = '1210 - Loans' GROUP BY LoanID HAVING SUM(Cramount)*26/(SUM(Dramount+Iamount)) < '" + TextBox111.text + "'"

我很确定 SQLite 支持在 having 子句中使用 agregate 字段的别名......

sql= "SELECT Fullname, GroupNo, Tdate, Schedule, (SUM(Cramount)*26)/SUM(Dramount+Iamount) AS ok FROM Trans WHERE Branchcode = '1210 - Loans' GROUP BY LoanID HAVING ok < '" + TextBox111.text + "'"

您的 SQL 还引用了您在表中未提及的两个字段,Branchcode 和 LoanID,希望您只是忘记提及它们。

于 2018-02-06T09:46:54.270 回答