Some oracle queries I keep on forgetting


top-N Query:

In Oracle, selecting the top-N query is sometimes very useful. In order to do it, first use an inline view to obtain all data in a sorted order. Then utilize the imaginary row numbering column, rownum, to determine the top number of rows to output. For example:

select account_no, discharge_date, rownum from (select * from encounter order by discharge_date) where rownum <=10;

equal Ignore Case:

select * from order where upper(order.choice) like ‘YES’

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s