subquery

Oracle glossary: in, not in

IN e NOT IN sono condizioni. Utili per testare uno o più valori in merito all’appartenenza (o meno) da una lista di valori di una subquery Un po’ di esempi: select * from table where col1 in (23, 45, 342) — dove il valore col1 corrisponde a uno o più valori tra 23, 45, 342 select * from table where col1 not in (23, 45, 342) — dove il valore col1 non corrisponde a uno o più valori tra 23, 45, 342 select * from table where (col1, col2) in (select val_a, val_b from testtab) — dove i valori di Continua a leggere

Oracle glossary: Subquery

Una subquery è una query sql contenuta in un’altra query sql. Un po’ di esempi: select tab.name, tab.surname from (select name, surname from customer where surname like ‘S%’) tab select id from myusers where (name, surname) in (select name, surname from customer where surname like ‘S%’) tab select (select ‘1’ from dual) from table.

A subquery example

Normal 14 false false false IT X-NONE X-NONE We happened recently to solve a problem of this type: we had a structure in which, for each category (shown in a table A) had a number of items of detail (in a table B) numeric values ​​(the latter given in a table C that implemented them a one to many relationship between A and B). We were required to get the maximum value for each category and detail which he was associated. The following example is inspired from the problem that we faced. For obvious reasons, the logic was applied to Continua a leggere