I just want to get the first result of this query but whenever I write down LIMIT. Oracle SQL Developer throws me this error   *ORA-00933: SQL command not properly ended 00933. 00000 -  "SQL command not properly ended" *Cause: Action: Error at Line: 6 Column: 7  Here is the Code:  SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR,  COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c  FROM PARRANDEROS.FRECUENTAN GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR ORDER BY c DESC )   LIMIT 1;   I've tried this method too:  SELECT IDBAR FROM ( SELECT PARRANDEROS.FRECUENTAN.ID_BAR as IDBAR,  COUNT(PARRANDEROS.FRECUENTAN.ID_BAR) c  FROM PARRANDEROS.FRECUENTAN GROUP BY PARRANDEROS.FRECUENTAN.ID_BAR ORDER BY c DESC LIMIT 1  );   Thanks a Lot.
13936
Is there a way to make an Oracle query behave like it contains a MySQL limit clause? In MySQL, I can do this: select *  from sometable order by name limit 20,10  to get the 21st to the 30th rows (skip the first 20, give the next 10). The rows are selected after the order by, so it really starts on the 20th name alphabetically. In Oracle, the only thing people mention is the rownum pseudo-column, but it is evaluated before order by, which means this: select *  from sometable where rownum &lt;= 10 order by name  will return a random set of ten rows ordered by name, which is not usually what I want. It also doesn't allow for specifying an offset.
74456
I want to write a query like this:  SELECT o.OrderId, MAX(o.NegotiatedPrice, o.SuggestedPrice) FROM Order o   But this isn't how the MAX function works, right?  It is an aggregate function so it expects a single parameter and then returns the MAX of all rows.     Does anyone know how to do it my way?
34471
What is wrong in the below trigger syntax, I am getting this error An unexpected token "INT" was found following " DECLARE NULL_ROW_ID".  Expected tokens may include:  "END-OF-STATEMENT".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.68.61  CREATE TABLE A (     A_ID INT NOT NUll,     A_CODE VARCHAR(100) NOT NULL,     PRIMARY KEY(A_ID) );  CREATE TABLE B (     B_ID INT NOT NUll,     B_CODE VARCHAR(100) NOT NULL,     A_ID INT,     PRIMARY KEY (B_ID),     FOREIGN KEY (A_ID) REFERENCES A (A_ID)  );  CREATE OR REPLACE TRIGGER B_TRIGGER AFTER UPDATE OF A_ID ON B REFERENCING NEW AS N OLD AS O FOR EACH ROW     WHEN (N.A_ID IS NULL)     BEGIN ATOMIC         DECLARE NULL_ROW_ID INT;         SET NULL_ROW_ID = (SELECT A_ID FROM A WHERE A_CODE = 'Custom Null String');         IF NULL_ROW_ID IS NULL THEN             SIGNAL SQLSTATE '70000' SET MESSAGE_TEXT = 'Custom Null String row not found.';         END IF;     SET N.A_ID = NULL_ROW_ID;     END @   It's on DB2 Express-C 10.5
64724
Using SOQL, how do I truncate an object or delete all rows. For example  DELETE (Select id FROM MyObject__c)   and  delete [select Id FROM MyObject__c]   and   TRUNCATE TABLE MyObject__c   All 3 example commands in the Developer console returns:  The query has to start with 'FIND' or 'SELECT'
17868
how do you count the number of columns in a table in oracle?
115371
Is it possible to build a single mysql query (without variables) to remove all records from the table, except latest N (sorted by id desc)?  Something like this, only it doesn't work :)  delete from table order by id ASC limit ((select count(*) from table ) - N)   Thanks.
10894
What's the difference between TRUNCATE and DELETE in SQL?  If your answer is platform specific, please indicate that.
21568
$sql = "SELECT Kill FROM tbl_pvporderview";   Problem is that I end up with: Incorrect syntax near the keyword 'Kill'.  Because kill is a T-SQL command... any way to bypass it?  I can't change the column name because it's used by the software a lot and I cant change the software that's using the database.  So it simply fails if I use sqlserv to select data from that column. '' or "" wont help.  The complete statement would be:  $sql = "SELECT serial,Kill FROM tbl_pvporderview WHERE Kill &gt; (?) ORDER BY Kill DESC ";
104379
Can I use this approach efficiently?  using(SqlCommand cmd = new SqlCommand("GetSomething", new SqlConnection(Config.ConnectionString)) {     cmd.Connection.Open();     // set up parameters and CommandType to StoredProcedure etc. etc.     cmd.ExecuteNonQuery(); }   My concern is : Will the Dispose method of the SqlCommand (which is called when exiting the using block) close the underlying SqlConnection object or not?
118306
I'm trying to convert a single-columned subquery into a command-separated VARCHAR-typed list of values.  This is identical to , but for Oracle rather than SQL Server or MySQL.
85357
/oracle/GR1/121/bin/sqlplus / as sysdba &lt;&lt;EOF &gt;&gt; $LOGFILE whenever sqlerror exit sql.sqlcode; set echo on; set serveroutput on; STARTUP; EXIT EOF   Already tried it with the path, but it hasn't worked.
118112
When I execute SOQL in Developer Console:  Select Id, Amount From Opportunity Where Amount &gt; 10000000000   An parsing error occurs:  Unknown error parsing query   Is there length limit of number on SOQL Where condition?
69005
Need help if anyone can offer! I currently have my select statement returning the TOP 1000 * results from a table. They are CC numbers that are currently active. I'd like to see how I can go about writing a query that could show me what has CC numbers have changed. If something has changed, it will send a report to the listed people. If nothing, then it does nothing. It only actions once something has happened. We have an inhouse system that will do the automated part... I just need a select statement that will return what has changed. If I can get some help on this, it would be amazing! Thank you!
43395
mknod /tmp/oracle.pipe p  sqlplus / as sysdba &lt;&lt; _EOF set escape on  host nohup gzip -c &lt; /tmp/oracle.pipe &gt; /tmp/out1.gz \&amp; spool /tmp/oracle.pipe select * from employee; spool off  _EOF  rm /tmp/oracle.pip   I need to insert a trailer at the end of the zipped file out1.gz , I can count the lines using  count=zcat out1.gz |wc -l   How do i insert the trailer  T5 (assuming count=5)   At the end of out1.gz without unzipping it.
54226
I have found a way to select random rows from a table in . A suggestion is to use the following query:  SELECT * FROM employee ORDER BY RAND() LIMIT 1   But when I run this query in MS SQL 2005, I get the following error message  Msg 102, Level 15, State 1, Line 1 Incorrect syntax near 'LIMIT'.   Can anyone tell me where am I wrong? Doesn't MS SQL support LIMIT? If so, then how can I do this?
3054
Is there any RDBMS that implements something like SELECT * EXCEPT?  What I'm after is getting all of the fields except a specific TEXT/BLOB field, and I'd like to just select everything else.  Almost daily I complain to my coworkers that someone should implement this...  It's terribly annoying that it doesn't exist.  Edit: I understand everyone's concern for SELECT *.  I know the risks associated with SELECT *.  However, this, at least in my situation, would not be used for any Production level code, or even Development level code; strictly for debugging, when I need to see all of the values easily.  As I've stated in some of the comments, where I work is strictly a commandline shop, doing everything over ssh.  This makes it difficult to use any gui tools (external connections to the database aren't allowed), etc etc.  Thanks for the suggestions though.
34123
My problem (or at least the error message) is very similar to .  My customer is working with an SQL select-query, containing a where-clause with exactly 100,000 entries.  The query is failing with error 8632 and error message      Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.)   I find it very peculiar that this error message is thrown, exactly at 100,000 entries, so I wonder if this is a configurable value. Is this the case and in case yes, how can I increase this value to a higher one?  On , there is the proposal to re-rewrite the query, but I'd like to avoid this.  Meanwhile I've found out that the list of entries I'm talking about contains natural numbers, quite some of them seem to be sequential (something like (1,2,3,6,7,8,9,10,12,13,15,16,17,18,19,20).  This makes the SQL where-clause something like:  where entry in (1,2,3,6,7,8,9,10,12,13,15,16,17,18,19,20)   I could transform this into:  where (entry between 1 and 3) OR       (entry between 6 and 10) OR       (entry between 12 and 13) OR       (entry between 15 and 20)   Can this be shortened by:  where entry in (1,...,3,6,...,10,12,13,15,...,20)   ...or something similar? (I know it's a long shot, but it would make software updates easier and more readable)  For your information: the data in the where-clause are the result of a calculation, done on another table: first the entries of that table are read and filtered at the beginning, then some extra processing is done (which is impossible to do using SQL), the result of that extra processing is more filtering and the result of that is used in the where-clause. As it was impossible to write the complete filtering in SQL, the mentioned method has been used. Obviously the content of the where-clause might change at every processing, hence the need of a dynamic solution.