Java Reference
In-Depth Information
select lastName as "Last Name" , zipCode as "Zip Code"
from Student
where deptId = 'CS' ;
Note
The as keyword is optional in MySQL and Oracle, but it is required in MS Access.
32.3.9 The Arithmetic Operators
You can use the arithmetic operators * (multiplication), / (division), + (addition), and -
(subtraction) in SQL.
Query 5: Assume that a credit hour is 50 minutes of lectures and get the total minutes for
each course with the subject CSCI. The query result is shown in Figure 32.14.
select title, 50 * numOfCredits as "Lecture Minutes Per Week"
from Course
where subjectId = 'CSCI' ;
F IGURE 32.14
You can use arithmetic operators in SQL.
32.3.10 Displaying Distinct Tuples
SQL provides the distinct keyword, which can be used to eliminate duplicate tuples in the
result. Figure 32.15a displays all the subject IDs used by the courses, and Figure 32.15b dis-
plays all the distinct subject IDs used by the courses using the following statement.
select distinct subjectId as "Subject ID"
from Course;
(a)
(b)
F IGURE 32.15
(a) The duplicate tuples are displayed. (b) The distinct tuples are displayed.
 
 
Search WWH ::




Custom Search