Navigation

2/16/2014

SQL Query for Invoices in Sierra

Below is a query that retrieves the invoice number and grand total for invoices paid during a specific date range to a specific vendor. Somebody at another library constructed it, which successfully retrieves this information for all vendors during a specific period:

SELECT
ir.invoice_number_text AS "Invoice Number",
ir.grand_total_amt AS "Total",
irs.vendor_code
FROM
sierra_view.invoice_record ir
JOIN
sierra_view.invoice_record_vendor_summary irs
ON irs.invoice_record_id = ir.id
WHERE
ir.paid_date_gmt BETWEEN '01/22/2014' AND '01/23/2014'
When you run this query, the correct vendor codes display in the data output, but when they added the following vendor condition to the WHERE clause, get no results.

WHERE
ir.paid_date_gmt BETWEEN '01/22/2014' AND '01/23/2014'
AND irs.vendor_code = ‘oing’

Turns out you need to say  irs.vendor_code = ‘oing ’
vendor code followed by space.  The vendor code field is defined as 5 characters, ansd any codes less than 5 characters get padded with trailing spaces

No comments:

Post a Comment