Postman collection
Invoices Read

pixiGetCountriesInvoice

Returns the distinct list of countries (code and name) that appear in the invoice addresses of all invoices.

Collects the country of the address linked to each invoice and returns each country once, with its code and name.

  • Every invoice in Invoices is joined to its address in Addresses via AddrRef = AddrKey. Invoices without a matching address are left out.
  • The country value of the address is looked up in the countries table by CntCode.
  • The result is deduplicated (DISTINCT) and sorted by CntName ascending.

The call has no parameters and always covers all invoices in the database.

Notes

  • The lookup in countries is a LEFT JOIN. If an address contains a country value that does not exist in countries (or is empty/NULL), a row with CntCode and CntName both NULL is returned. Because of the ascending sort on CntName, this row appears first.
  • The unmatched country value itself is not returned, only the NULL columns.
  • Invoices and Addresses are read with NOLOCK (dirty reads possible); countries is read without a locking hint.
  • The query scans all invoices; on large databases the call can take some time.

Tables used

Invoices · Read Addresses · Read countries · Read
SQL object:
dbo.pipiGetCountriesInvoice
Updated at 2026-10-30