Explanation: The dataset is segmented based on the CLCIKS column. This creates two groups: one with CLCIKS values of 100 and the other with a null CLCIKS value. The average length of CLCIKS value 100 is 3 for the rows in the first group. The NULL CLCIKS value is first converted into the number 0 by the NVL function, and the average length of CLCIKS is 1. The SUM function operates across the two groups adding the values 3 and 1, returning 4.
Question : How would I write an Oracle DELETE statement to delete all records in TableA whose data in field and field DO NOT match the data in fieldx and fieldz of TableB?
1. DELETE FROM TableA WHERE NOT EXIST ( SELECT * FROM TableB WHERE TableA.field1 = TableB.fieldx AND TableA.field2 = TableB.fieldz ); 2. DELETE FROM TableA WHERE IN ( SELECT * FROM TableB WHERE TableA.field1 = TableB.fieldx AND TableA.field2 = TableB.fieldz ); 3. Access Mostly Uused Products by 50000+ Subscribers WHERE NOT IN ( SELECT * FROM TableB WHERE TableA.field1 = TableB.fieldx AND TableA.field2 = TableB.fieldz ); 4. DELETE FROM TableA WHERE NOT EXISTS ( SELECT * FROM TableB WHERE TableA.field1 = TableB.fieldx AND TableA.field2 = TableB.fieldz );
Explanation: ou can also perform more complicated deletes.
You may wish to delete records in one table based on values in another table. Since you can't list more than one table in the Oracle FROM clause when you are performing a delete, you can use the Oracle EXISTS clause.
For example:
DELETE FROM suppliers WHERE EXISTS ( SELECT customers.customer_name FROM customers WHERE customers.customer_id = suppliers.supplier_id AND customer_id > 25 ); This Oracle DELETE example would delete all records in the suppliers table where there is a record in the customers table whose customer_id is greater than 25, and the customer_id matches the supplier_id. If you wish to determine the number of rows that will be deleted, you can run the following Oracle SELECT statement before performing the delete. SELECT COUNT(*) FROM suppliers WHERE EXISTS ( SELECT customers.customer_name FROM customers WHERE customers.customer_id = suppliers.supplier_id AND customer_id > 25 );
Question : Select the statement which is not correct ? 1. SELECT department, SUM(sales) AS "Total sales" FROM order_details GROUP BY department HAVING SUM(sales) > 25000; 2. SELECT department, COUNT(*) AS "Number of employees" FROM employees WHERE salary & lt; 49500 GROUP BY department HAVING COUNT(*) > 10; 3. Access Mostly Uused Products by 50000+ Subscribers FROM employees GROUP BY department HAVING MIN(salary) & lt; 42000; 4. 1 and 3
Explanation: The syntax for the Oracle HAVING Clause is:
SELECT expression1, expression2, ... expression_n, aggregate_function (expression) FROM tables WHERE conditions GROUP BY expression1, expression2, ... expression_n HAVING condition; Parameters or Arguments
aggregate_function can be a function such as SUM, COUNT, MIN, MAX, or AVG functions.
expression1, expression2, ... expression_n are expressions that are not encapsulated within an aggregate function and must be included in the GROUP BY Clause.
condition is the condition that is used to restrict the groups of returned rows. Only those groups whose condition evaluates to TRUE will be included in the result set.
END IF; 1. SELECT COMPOSE( address1, address2, address3 ) result FROM suppliers; 2. SELECT COALESCE( address1, address2, address3 ) result FROM suppliers; 3. Access Mostly Uused Products by 50000+ Subscribers FROM suppliers; 4. SELECT NVL( address1, address2, address3 ) result FROM suppliers;