,ch04.13730 Page 166 Wednesday, November 29, 2000 4:43
,ch04.13730 Page 166 Wednesday, November 29, 2000 4:43 PM Aggregate functions are used often in the HAVING clause of queries with GROUP BY. The following query selects all categories (types) of books that have an average price for all books in the category higher than $15.00: SELECT type ‘Category’, AVG( price ) ‘Average Price’ FROM titles GROUP BY type HAVING AVG(price) > 15 Scalar Functions Scalar functions fall into the categories listed in Table 4-2. Table 4-2: Categories of Scalar Functions Function Category Explanation Built-in Date & Time Numeric String Performs operations on values or settings built into the database. Oracle uses the term built-in to describe all the specialty functions that are provided by Oracle, and thus built into their DBMS. This is a distinct and separate usage from the built-in functions described here. Performs operations on datetime fields and returns values in datetime format. Performs operations on numeric values and returns numeric values. Performs operations on character values (char, varchar, nchar, nvarchar, and CLOB) and returns a string or numeric value. Note that CASE and CAST are both functions. However, they are detailed in Chapter 3 because of their complexity and frequent usage in SQL-data statements. Built-in Scalar Functions SQL99 built-in scalar functions identify the current user session, and also characteristics of the current user session, such as the current session privileges. Built-in scalar functions are almost always nondeterministic. The first three functions listed in Table 4-3 are built-in functions that fall into the date-and-time category of functions. Although the four vendors provide many additional functions beyond these SQL built-ins, the SQL standard declares only those listed in Table 4-3. Table 4-3: SQL99 Built-in Scalar Functions Function CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURRENT_USER SESSION_USER SYSTEM_USER Usage Identifies the current date. Identifies the current time. Identifies the current date and time. Identifies the currently active user within the database server. Identifies the currently active Authorization ID, if it differs from the user. Identifies the currently active user within the host operating system. 166 Chapter 4 SQL Functions
Note: If you are looking for good and high quality web space to host and run your application check Lunarwebhost PHP MySQL Web Hosting services