Select Clause Examples

In the sample query statement below, the prefix "part" in front of the CITY column (separated with a period) tells the system to use the CITY column from the PART table, rather than from the SUPPLIER table.

SELECT pno, part.city, qty, sname
FROM partsupp, supplier, part
WHERE part.pno = partsupp.pno
  AND partsupp.sno = supplier.sno

If columns are not prefixed with the name of the owner table, the XDB Server queries the first column with that name that the system encounters.

The next sample query adds a five percent surcharge on all outstanding customer balances in the state of Maryland, and then lists the new adjusted balance for each affected company.

SELECT company,
  balance + balance * .05 AS New_Balance
FROM customer
WHERE state = MD

The AS clause expression calculates the adjusted balance, which it displays under the heading New_Balance.