Database Reference
In-Depth Information
FROM BILLING
WHERE ServiceCode = 'SCAN') )
6. Obtain a list of all billings including those patients for whom no billings have
been done until now.
SELECT BILLING.PatientNo, PatientName, BilledAmount
FROM BILLING, PATIENT
WHERE BILLING.PatientNo = PATIENT.PatientNo
UNION
SELECT PatientNo, PatientName, 0
FROM PATIENT
WHERE PatientNo NOT IN
(SELECT PatientNo
FROM BILLING)
Summary of SQL Query Components
Having reviewed various types of SQL queries, let us summarize the different query
components. Figure 13-12 provides a summary of the main clauses, operators, and
built-in functions that are part of typical SQL queries.
Database Access from Application Program
The queries discussed in the previous subsection illustrate one method of using
SQL. We have covered the interactive use of SQL. To obtain the desired results
from the database, you write SQL code in the database environment. The com-
mercial database systems support SQL and execute the SQL statements interac-
tively. The end of the SQL code, usually signified by a semi-colon (;), triggers the
SELECT
GROUP BY
HAVING
ORDER BY
Retrieval
SUM
AVG
COUNT
DISTINCT
MIN
MAX
S Q L
Update
INSERT
DELETE
UPDATE
Figure 13-12
SQL query and manipulation components.
Search WWH ::




Custom Search