As you learned in previous article, the LIKE operator is used in character string comparisons with pattern matching it compares a character, string, or CLOB value to a pattern and returns TRUE if the value matches the pattern and FALSE if it does not. The pattern can include the two "wildcard" characters underscore (_) and percent sign (%).
And the subquery is a SELECT statement that is nested within another SQL statement it is often referred to as an inner query, and the statement within which it occurs is then called the outer query. There is nothing wrong with this terminology, except that it may imply that you can only have two levels, inner and outer.
A subquery can also have LIKE Operator, With the subquery out of the way, the containing query can now be evaluated they are most often found in the WHERE clause of a SELECT, UPDATE, or DELETE statement, as well as in the SET clause of an UPDATE statement.
Here you see how can we use this two PL/SQL statements together:
Example:
SQL> SELECT COUNT(*) Total_Stores, a.Brand
2 FROM dba_objects a
3 WHERE a.Brand NOT IN (SELECT b.Brand FROM dba_objects b
4 WHERE b.Brand LIKE 'S%')
5 GROUP BY a.Brand;
Total_Stores Brand
-------------- --------------
1473 Pepssi
233 Hindustan
143 Cola
2389 Unilever
68 OUTLN
575 Bacardi
339 Nutralite
434 Cga
102 Amway
146 Oreflame
10 rows selected.


0 comments:
Post a Comment