Skip to content

Tag: oracle

How to retrieve half of records from a table – Oracle 11g

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…

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.…

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 …

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