Oracle
 SQL >> Database >  >> RDS >> Oracle

Usare la funzione REPLACE in Oracle SQL per generare espressioni

È davvero strano. Piuttosto, ribaltiamo le cose e ordiniamo in ordine inverso:

select replace(replace('count(distinct <thiscol>) over (partition by <nextcol>) / count(*) over () as <thiscol>_<nextcol>,', '<thiscol>', column_name ), '<nextcol>', lead(column_name) over (order by column_id desc) ) from all_tab_columns atc where table_name = 'mytable'; 

Nota il desc nell'ordinamento.