oracle - How to write a sql query for below condition -


i have 2 query selecting data same table

query1 :

select rownum rn , error_data_log  ext_tab_log  error_data_log like'error%'  order rn, error_data_log ;  

result :

+----+--------------------------+ | rn |  error_data_log          | +----+--------------------------+ | 1  |  error processing column | +----+--------------------------+ 

query 2 :

select rownum rn , error_data_log  ext_tab_log  error_data_log 'kup-04101%'  order rn, error_data_log ; 

result :

+----+----------------------------------------------+ | rn | error_data_log                               | +----+----------------------------------------------+ | 1  | kup-04101: record 1 rejected in file abc.txt |    | 2  | kup-04101: record 8 rejected in file abc.txt |   | 3  | kup-04101: record 9 rejected in file abc.txt | +----+----------------------------------------------+   

how can write sql query obtain below result:

+----+----------------------------------------------+  | rn | error_data_log                               | +----+----------------------------------------------+ | 1  | error processing column                      | | 2  | kup-04101: record 8 rejected in file abc.txt | +----+----------------------------------------------+ 

if understand correctly, can try this:

select rownum rn , error_data_log      select rownum rn , error_data_log, 1 querynum     ext_tab_log      error_data_log like'error%'       union      select rownum rn , error_data_log, 2 querynum     ext_tab_log      error_data_log 'kup-04101%'      group rn , error_data_log, querynum     having rn > 1 , rn < max(rn)  ) unionselect    order querynum, rn, error_data_log ; 

note: sql written directly here, didn't try myself.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -