I have a UNION query that I pass two parameters to but those two parameters are used in both sides of the union.
SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill LEFT JOIN tbl_from_xl ON bill.voucher_nbr = tbl_from_xl.voucher_nbr
Where bill.TripDate BETWEEN FromDate AND ToDate
ORDER BY bill.voucher_nbr
UNION
SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill RIGHT JOIN tbl_from_xl ON bill.voucher_nbr=tbl_from_xl.voucher_nbr
WHERE tbl_from_xl.TripDate BETWEEN FromDate AND ToDate OR tbl_from_xl.BillingMonth BETWEEN FromDate AND ToDate;
As you can see, I am using FromDate and ToDate but on two separate tables.
My question is can I get this to only prompt me for the parameters once rather than prompting me 4 times each time I run the query?
Thanks.
SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill LEFT JOIN tbl_from_xl ON bill.voucher_nbr = tbl_from_xl.voucher_nbr
Where bill.TripDate BETWEEN FromDate AND ToDate
ORDER BY bill.voucher_nbr
UNION
SELECT bill.TripDate AS Bill_TripDate, bill.voucher_nbr AS Bill_Voucher, bill.fare AS Bill_Fare, tbl_from_xl.TripDate AS XL_TripDate, tbl_from_xl.voucher_nbr AS XL_Voucher, tbl_from_xl.fare AS XL_Fare
FROM tbl_from_bill AS bill RIGHT JOIN tbl_from_xl ON bill.voucher_nbr=tbl_from_xl.voucher_nbr
WHERE tbl_from_xl.TripDate BETWEEN FromDate AND ToDate OR tbl_from_xl.BillingMonth BETWEEN FromDate AND ToDate;
As you can see, I am using FromDate and ToDate but on two separate tables.
My question is can I get this to only prompt me for the parameters once rather than prompting me 4 times each time I run the query?
Thanks.