Examples of Complex Queries
The remainder of today focuses on complex queries. We have included example SQL queries, example output, and explanations of each example. As we go through each example, you may want to review the section of this book that talks about each command, operator, and function.
Computing Age from Date of Birth
It is generally rare that you would store an individual's age in a database. The age is a dynamic value that changes every day. Conversely, you would store a more static value, such as the date of birth. By comparing the date of birth with the current date, you can easily determine an individual's age. The following query will determine an individual's age in years:
select ((sysdate - dob) / 365) age from mem_profile_tbl; ...