Aliasing Field Names with ASSQL gives you the ability to alias, or rename, a field or expression in a query. (We used this capability in both examples in the preceding section.) You typically need to alias a field for two reasons:
Whatever your reason for wanting to alias a field name, it's easy to do with the AS clause in SQL. For example, say that you're doing a complex series of calculations to determine the extended price on invoices (the extended price is the item price multiplied by the quantity shipped). You also want to refer to the calculated column as ExtendedPrice. You can do so by writing the SQL code SELECT TOP 5 ItemID, Quantity, Price, tblInventory Retail Price * tblOrderItem.Quantity AS ExtendedPrice FROM tblOrderItem INNER JOIN tblInventory ON tblOrderItem.ItemID = tblItem.ID This query produces the following result set.
The entries in the ExtendedPrice field aren't stored in the database; they're calculated on the fly. |