Skip to content

Tag: oracle

In sql how do you print only the most occuring

This actually tells us which person made the most purchases. But how can i print only the top row and not have all the other rows below? Answer You want to fetch the highest ranked row(s) of your intermediate result. If you want to keep your query as is and only add the appropriate clause, use FETCH and a mod…

How to print pattern output in Oracle’s SQL

I have a table with below data Table : emp name A B C D Expected Output : names A AB ABC ABCD I only know how to print data in horizontal form Not sure how to cut the horizontal and get expected output Answer You can use a hierarchical query: Which, for the sample data: Outputs: NAMES A AB

how to retrive data from VARRAY and filter it

i have to retrieve specific data from Varray for example i want to retrieve the name where VARRAY includes AC1 i tried select * from exprement where seat=’AC1′; Answer You can use: or As an aside, if you defined seat as a nested table (rather than a VARRAY) then you could use the MEMBER OF operato…

Selecting last record in plsql

Hello I need to select last record in a table(bill_account_billcycle). After finding it I need to take bill_date column date from last record and need implement inside my cursors’ query. I read rownum max etc but couldnt succeed to implement. I am open to advices. I am going to add a screenshoot of one …

SQL – How to print calculated datetime result

If a.modified_datetime is ‘2021/10/01 13:00:00’ and b.modified_datetime is ‘2021/10/01 12:30:00’, the result of this query would be: However, I run this query via sqlplus, it returns What’s wrong with this query, or need to set some options to sqlplus? Answer it is stored in a da…