invoice
我有以下 SQL 来提取给定的最新 SQLbill
SELECT "invoices".* FROM "invoices" WHERE "invoices"."bill_id" = ? ORDER BY issue_date DESC LIMIT 1
我为一组中的每个运行它bill_id
,比如说[1, 5, 7, 9]
。有没有办法只用一个来执行这 4 个 SQL 命令?
编辑:: 澄清一下,我有 4 张账单,每张账单都有多张发票。我想要每张账单的最新发票。所以一共4张发票。
架构:
CREATE TABLE "bills" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(255))
CREATE TABLE "invoices" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "issue_date" datetime, "amount_cents" integer, "bill_id" integer)