select sum(rashody)/count(distinct data_prikaza_) over(partition by gosb) from erp_trips
select sql_text, sql_fulltext from v$sql where MODULE = 'имя макроса который написан на C++'
одним селектом
INSERT ALL
INTO table_name(col1) VALUES(val1)
INTO table_name(col1) VALUES(val4)
INTO table_name(col1) VALUES(val7)
SELECT * FROM dual;
begin
insert into ..... returning id into :id;
-- ...
commit;
end;
SELECT TO_DATE('September 11, 2019, 5:02:44 PM', 'MONTH DD, YYYY, HH:MI:SS AM', 'NLS_DATE_LANGUAGE=AMERICAN') FROM DUAL;
alter session set NLS_LANGUAGE=AMERICAN
select * from nls_session_parameters where parameter = 'NLS_DATE_LANGUAGE';
SELECT cast (TO_DATE('September 11, 2019, 5:02:44 PM', 'MONTH DD, YYYY, HH:MI:SS AM','NLS_DATE_LANGUAGE=AMERICAN') AS TIMESTAMP) FROM DUAL;
BEGIN
UPDATE kolesa_brands SET name = 'name' WHERE id = <id>;
IF SQL%NOTFOUND THEN
INSERT INTO kolesa_brands (id, name) VALUES (<id>, '<name>');
END IF;
END;
<id>, <name>
нужно подставить значения $opt->value и $opt->plaintext). Так как для merge нужно две таблицы можно попробовать использовать виртуальную таблицу dualmerge into kolesa_brands t
using ( select <id> id, '<name>' name from dual ) n on ( t.id = n.id)
when matched then
update set t.name = n.name
when not matched then
insert (t.id, t.name) values (n.id, n.name)
<blockquote>require_once "simple_html_dom.php";
error_reporting(E_ALL);
ini_set('display_errors', '1');
$conn = oci_connect('ddd', 'ddd', '127.0.0.1/orcl', 'AL32UTF8');
$brands = array();
$html = str_get_html(file_get_contents('https://kolesa.kz/cars/'));
$i = 'begin ';
$i .= '\r\n';
$select = $html->find('select[id=auto-car-mm-0]', 0);
foreach($select->find('option') as $opt)
{
if($opt->value == '') continue;
$i .= 'merge into kolesa_brands t ';
$i .= 'using (select '.$opt->value.' id, \''.$opt->plaintext.'\' name from dual) n on (t.id = n.id) ';
$i .= 'when matched then ';
$i .= 'update set t.name = n.name ';
$i .= 'when not matched then ';
$i .= 'insert (t.id, t.name) values (n.id, n.name);';
$i .= '\r\n';
$brands[$opt->value] = $opt->plaintext;
}
$i .= '\r\n';
$i .= 'end;';
$insert = oci_parse($conn, $i);
oci_execute($insert);</blockquote>
INSERT INTO kolesa_brands (id, name) VALUES (4, 'ARO'), (1, 'Acura'), (2, 'Alfa Romeo')
select t2.UserName
from TAB1 t1
left join TAB2 t2 on t2.UserID = t1.UserID
where (t1.cat = 1 AND t1.group IN (3,10,9))
OR (t1.cat = 4 AND t1.group IN (1,2,3,20))
-- неопределенное количество условий вхождения в группы и категории
group by t2.UserName
SELECT T1.PRIVILEGE,
T1.ADMIN_OPTION SYS_USER,
T2.ADMIN_OPTION MY_USER
FROM DBA_SYS_PRIVS T1
LEFT JOIN DBA_SYS_PRIVS T2 ON T1.PRIVILEGE = T2.PRIVILEGE
AND T2.GRANTEE = 'MY_USER'
WHERE T1.GRANTEE = 'SYS'
ORDER BY T1.PRIVILEGE ASC