Skip to content

Tag: oracle

SQL CASE Statement for no data

I have a table that has process engines 1,2,3,4,5,6 with a running status. When one of the engines is down the record gets deleted from the table. Using a case statement I can display the first engine that is down but how do I go about displaying the engines if 2 or more engines are down. For e.g. how do

How to Select Top 100 rows in Oracle?

My requirement is to get each client’s latest order, and then get top 100 records. I wrote one query as below to get latest orders for each client. Internal query works fine. But I don’t know how to get first 100 based on the results. Any ideas? Thanks. Answer Assuming that create_time contains th…

Select distinct returns duplicates

I have the following query: But it returns duplicates in TK.TICKETID attribute. And if i remove other attributes all ok. e.g. How can I return only a single record per TK.TICKETID? Answer Try this:

Set server output only in spool

Is it possible to set the server output only into the spool file and not in the shell ? Inside MY_PROCEDURE I have this : I would like to put Hello World only in log.txt, not in the screen shell. Answer Simplest way is to pipe the unix output to /dev/null

How to give comments in SQL

I am working in SQL. What is the complete explanation for using comments in SQL, with some example code? Answer MySQL Server supports three comment styles: From a # character to the end of the line. From a — sequence to the end of the line. In MySQL, the “– ” (double-dash) comment style requires t…