Database Reference
In-Depth Information
Figure 4.3
Column Aliases
Can Help Make
Queries More
Readable.
were handing a report off to someone else, you might want a more descrip-
tive heading. To change the heading, add a column alias to the SELECT
statement. A column alias redefines a column's heading in a SELECT state-
ment. In this example, we change the second line by adding the alias “Bal-
ance Due.”
AMOUNT_CHARGED-AMOUNT_PAID
"Balance Due"
Using double quotes preserves the upper and lowercase appearance of
the heading. Without double quotes, your alias will always appear in upper-
case letters in the report. Additionally, in this case because the words “Bal-
ance” and “Due” are separated by a space, “Due” will be interpreted as a
column name, causing an error. Figure 4.3 shows the output.
Now add aliases to all three columns and change the SELECT statement
again:
SELECT ARTIST_ID
Artist
, SESSION_DATE
"In Studio"
, AMOUNT_CHARGED-AMOUNT_PAID
"
Balance Due
"
FROM STUDIOTIME;
Search WWH ::




Custom Search