The single query is one SELECT statement, whereas the compound query includes two or more SELECT statements. Compound queries are formed by using some type of operator to join the two queries. The UNION operator in the following examples is used to join two queries. A single SQL statement could be written as follows : SELECT EMP_ID, SALARY, PAY_RATE FROM EMPLOYEE_PAY_TBL WHERE SALARY IS NOT NULL OR PAY_RATE IS NOT NULL; This is the same statement using the UNION operator: SELECT EMP_ID, SALARY FROM EMPLOYEE_PAY_TBL WHERE SALARY IS NOT NULL UNION SELECT EMP_ID, PAY_RATE FROM EMPLOYEE_PAY_TBL WHERE PAY_RATE IS NOT NULL; The previous statements return pay information for all employees who are paid either hourly or salaried. | If you executed the second query, the output has two column headings: EMP_ID and SALARY. Each individual's pay rate is listed under the SALARY column. When using the UNION operator, column headings are determined by column names or column aliases used in the first SELECT of the UNION. | |