How can i retrieve (select) half of records from a table, for example, a table with 1000 rows, retrieve 500 (50%) from the table. (in this case i can use rownum because we know the exact quantity of rows (1000) – select * from table where rownum <= 500), but i have to count every table to achieve the…
Tag: oracle
Reuse a parameter in a PreparedStatement?
I am passing a parameter to a PreparedStatement like this : And the query looks like this : Now I want to modify my query like this, and reuse the first parameter (both ? would use the runId parameter) : Is that possible without doing this : Answer This cannot be done with plain JDBC. You could instead use Sp…
Oracle Sql: How to add multi sub total in sql?
I want query multi sub total in query sql. How query multi sub total. please help me. SQL CODE: Result Query: But i want add multi sub total in query. I want Result Query: How add multi row sub total? Help me please. Thanks in advance. 😉 Answer I will post a solution with using the group by rollup extension.…
How to query the distribution (grouped by value range) of a column value in Oracle?
Suppose there is a table called DISTANCES in Oracle with a float type column named distance. The range of distance is from [0, 1000]. I want to know the distribution of the distances, for example, how …
Oracle SQL Groupby and SUM
I have the following query that groups every tender id and description and shows its total Sum: 3020 American Express 20 1000 Cash – primary currency 9903.25 3120 House Card …
How do I solve this (SQL) query? [closed]
This is probably one of the simplest queries ever, and I’m probably just making it harder than it has to be, but I need it done. So, there’s three tables: TABLE AGENT ( A_ID INTEGER PRIMARY KEY, …
Query with rownum got slow
I have got a table table with 21 millions records of which 20 millions meet the criterion col1= ‘text’. I then started iteratively to set the value of col2 to a value unequal to NULL. After I have mutated 10 million records, the following query got slow, that was fast in the beginning: I noticed t…
How can a query select dates from only a specific academic year?
This may be simple, but I cannot figure out the correct and simplest way to query a table which contains a date col to return the rows in which the date belongs to the current academic year. Knowing that for academic year I mean the period from the 1st of September of a year to the 31st of august of
SQL not recognizing column alias in where clause
I am only a beginner in SQL, but I’ve come across this annoying error. SQL is having an issue with the WHERE clause of this script: SELECT ITEM_ID, ITEM_PRICE, DISCOUNT_AMOUNT, QUANTITY, (…
How do I list all tables in a schema having specific column in oracle sql?
I have found the list of all tables using this query – But I need to list all the tables having column name starttime_date or starttime. Answer You could use USER_TAB_COLS view. For example, You could try,