我正在为一个班级建立一个婚礼数据库,目前有一个费用表。该表显示费用标签(鲜花,摄影师,乐队......)和付款到期日(以及其他内容)。我还有一个单独的表用于其他任务(询问新娘派对,发送邀请....)。
我目前有一个Union Query,它将两个表合并为一个“待办事项列表”。这是查询的sql:
SELECT Expense AS Task, DateDue, tblExpenses.[Paid?] AS [Completed?]
from tblExpenses
UNION SELECT Task, DateDue, tblToDoList.[Completed?]
from tblToDoList;
我的问题是最终列表按计划合并,但列表中的“花朵”等值位于“任务”标题下。我希望能够在费用表的值前添加“付费”或“付费”,以便它像谓词而不是主题一样读取。有没有办法做到这一点?
很抱歉,如果其中任何一个令人困惑。我对SQL的了解非常有限,我不确定如何准确地说出一切。
答案 0 :(得分:0)
怎么样??
SELECT Expense AS Task, DateDue,
IIf(tblExpenses.[Paid?]=True,"Paid","Pay For") AS [Completed?]
FROM tblExpenses
UNION
SELECT Task, DateDue, tblToDoList.[Completed?]
FROM tblToDoList;
如果付款为真(是),查询将返回"付费"否则将返回"支付"。
重新评论
SELECT "Paid " & Expense AS Task, DateDue,
tblExpenses.[Paid?] AS [Completed?]
FROM tblExpenses
UNION
SELECT Task, DateDue, tblToDoList.[Completed?]
FROM tblToDoList;