我有一个查询,它将检查一张表中的作废发票,然后检查同一张表以查看作废的发票是否被重新投标。我想知道...是,有没有办法添加一列来查看无效发票是否没有重新投标,并在列中将其列为“N”..
这是我当前的查询:
SELECT t1.Store_Number, t1.Invoice_Number, t1.Invoice_Date, t1.Vehicle_Tag, t1.Void_Reason, t1.Void_Employee_Tax_Payer_Id, t1.Invoice_Total, t1.Void_Flag,
t2.Invoice_Number AS Expr1, t2.Vehicle_Tag AS Expr2, t2.Invoice_Total AS Expr3
FROM Invoice_Tb AS t1 INNER JOIN
Invoice_Tb AS t2 ON t1.Vehicle_Tag = t2.Vehicle_Tag
WHERE (t1.Void_Flag = 'y') AND (t1.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102)) AND
(t2.Void_Flag = 'n') AND (t2.Invoice_Date BETWEEN CONVERT(DATETIME, '2012-08-01 00:00:00', 102) AND CONVERT(DATETIME, '2012-08-02 00:00:00', 102))
这是我当前的输出:
Store Number Invoice Number Date Plate Number Void Reason Employee Invoice Amount Voided New Invoice Number Plate Number New Invoice Amount Re-Tendered
1568 3257714 8/1/2012 0:00 BBY1234 WRONG PRICE ENTERED 89556532 21.39 3257714 BBY1234 26.74 Y
我想要的一个示例:假设发票 #123 已作废,并且从未重新投标...我想显示上述内容并添加一个列标题“重新投标”并在发票所在的位置列出“n”没有重新招标。输出将与此类似:
Store Number Invoice Number Date Plate Number Void Reason Employee Invoice Amount Voided New Invoice Number Plate Number New Invoice Amount Re-Tendered
1568 3257714 8/1/2012 0:00 BBY1234 WRONG PRICE ENTERED 89556532 21.39 3257714 BBY1234 26.74 Y
1552 123 8/1/2012 0:00 Dwb0534 Wrong Plate number 73215654 15.95 N