Database Reference
In-Depth Information
SELECT
S.
ARTIST_ID Artist,
S.
SESSION_DATE "In Studio"
,
S.
AMOUNT_CHARGED -
S.
AMOUNT_PAID "Balance Due"
FROM STUDIOTIME
S
;
You could even add a schema name and a table alias to the table name in
a SELECT command. For example, you are logged on as FRED and wish
to query the LONGBOAT table in ANGELA's schema:
SELECT
BOAT.
BOAT_NAME,
BOAT.
DATE_CHRISTENED
FROM
ANGELA.
LONGBOAT
BOAT
;
Here are a few more tips on writing good queries:
Use parentheses in either the SELECT or the WHERE clause to con-
trol the order of evaluation of expressions. Expressions within paren-
theses are evaluated first. For example:
SELECT (TOTAL_MORTGAGE-(MONTHLY_PMT * MONTHS_PAID))/36
Evaluates differently to:
SELECT (TOTAL_MORTGAGE-(MONTHLY_PMT * MONTHS_PAID)/36)
Upper and lowercase make no difference so long as they are not in
quotation marks. For example, these three statements are identical as
far as Oracle Database 10
g
is concerned:
SELECT Name, Street, City from artist;
Select name, street, city from ARTIST;
SelEct nAmE, strEet, CITy From aRTist;
When enclosed in quotation marks (single or double), then upper
and lowercase are considered different. For example, these two state-
ments are different:
SELECT * from artist where name like ('%C%');
SELECT * from artist where name like ('%c%');
Oracle Database 10
ignores line breaks and spacing in SQL com-
mands. For example, the following two SELECT statements are iden-
tical when submitted in SQL*Plus, even though spacing and line
breaks make them look completely different from each other.
g
SELECT Name
, Street
Search WWH ::




Custom Search