About 2,470,000 results
Open links in new tab
  1. sql - Oracle - add counter to query - Stack Overflow

    Dec 3, 2014 · The row_number analyitic function should do the trick: SELECT surname, ROW_NUMBER() OVER (ORDER BY surname) AS counter FROM my_table EDIT: In a simple query like this, you could just use the rownum pseudocolumn: SELECT surname, rownum FROM my_table ORDER BY 1 DESC

  2. Add a row number to result set of a SQL query - Stack Overflow

    Oct 21, 2022 · I want to add a temporary column that will represent number the of rows in my result set. I tried this - declare @num int set @num = 0; select t.A, t.B, t.C, (@count + 1) as number from tableZ as t

  3. oracle database - Add total row with sum count - Stack Overflow

    Oct 4, 2016 · If you get unique records through your query then you may use the below query also without using UNION ALL: SELECT COUNT(*) FROM CUSOMERS WHERE C_ID = 90. AND CONTRACT_TYPE = 80. AND CONTRACT_DATE >= TO_DATE('20160101', 'YYYYMMDD') . AND CONTRACT_DATE <= TO_DATE('20161231', 'YYYYMMDD') AND ORDER_ID = ORDERS.ID. AND STATUS = 1.

  4. Using Aggregate Functions

    The following functions are called SQL aggregate functions, because their semantics are similar to those in standard SQL: they work in conjunction with grouping and they aggregate values across the rows of a group. ... The count star function can be used when you want to count the rows of a resultant query. It does not accept any other input ...

  5. SQL%Rowcount equivalent for MERGE - Oracle Ask TOM

    Jun 12, 2023 · rows_affected = sql%rowcount select count(1) into after_count from my.table insert_count = after_count - before_count update_count = rows_affected - insert_count

  6. Oracle ROW_NUMBER Function - Oracle Tutorial

    To effectively use the ROW_NUMBER() function, you should use a subquery or a common table expression to retrieve row numbers for a specified range to get the top-N, bottom-N, and inner-N results. The ROW_NUMBER() function is useful for pagination in applications.

  7. Oracle Live SQL - Script: Row Count for Tables in the database

    select owner, table_name, nvl(num_rows,-1) rowcount from all_tables order by nvl(num_rows,-1) desc

  8. How SQL%ROWCOUNT works - Oracle Forums

    Apr 3, 2012 · How SQL%ROWCOUNT works ...............plz help PL/SQL code is: SET SERVEROUTPUT ON DECLARE avg_1 NUMBER; avg_2 NUMBER; var_rows NUMBER; BEGIN SELECT AVG (salary) INTO avg_1 FROM employees wher...

  9. Oracle COUNT Function - Oracle Tutorial

    COUNT(DISTINCT expression) function returns the number of unique and non-null items in a group. COUNT(ALL expression) evaluates the expression and returns the number of non-null items in a group, including duplicate values. If you don’t explicitly specify DISTINCT or ALL, the COUNT() function uses the ALL by default.

  10. Adding Total Rows to SQL Query - Oracle Forums

    Oct 20, 2015 · I currently have the following SQL Statement: SELECT B.MDA_LEV3_DEPT_NAME AS "EVP Area", COUNT(CASE Z.MDA_EPAF_STATUS WHEN 'C' THEN 1 END) AS Approved, COUNT(CASE Z.MDA_EPAF_STATUS WHEN 'A' THEN 1 END) AS "In Progress", COUNT(CASE Z.MDA_EPAF_STATUS WHEN 'E' THEN 1 END) AS Draft FROM PS_MDA_EPAF_RQST Z,