Blog Archives

Oracle-Use ROWNUM To Return Row Count

Oracle ROWNUM Reserved Field Use reserved field, ROWNUM in SELECT Statement to return record number in the data output: SELECT ROWNUM, FIELD1, FIELD2, FIELD3 FROM YOUR_TABLE Returns: ROWNUM FIELD1 FIELD2 FIELD3 1 F1VAL1 F2VAL1 F3VAL1 2 F1VAL2 F2VAL2 F3VAL2 3

Tagged with: , ,
Posted in Oracle

SQL – Select Top N From

Select Top N from SQL Server Oracle RowNum pseudocolumn. SQL Server and Oracle allow you to run a Select Statement, but limit the number of rows returned. This is very useful if you just need to see a snapshot of

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Replace Statement

REPLACE STATEMENT The Replace Statement replaces all instances of a specified string value with a new value. Syntax: REPLACE(Field Name, Search String, New String) SQL Server: SELECT REPLACE(FIELD1,’/’,’-‘) FROM TABLE Oracle: SELECT REPLACE(FIELD1,’/’,’-‘) FROM TABLE;  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Character Case Functions

Character Function – Returns the Character from a given character code SQL Server SELECT CHAR(65) + CHAR(66) + CHAR(67) Returns ABC Oracle: SELECT CHR(65) || CHR(66) || CHR(67) FROM dual; Returns ABC  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Char Function

Character Function – Returns the Character from a given character code SQL Server SELECT CHAR(65) + CHAR(66) + CHAR(67) Returns ABC Oracle: SELECT CHR(65) || CHR(66) || CHR(67) FROM dual; Returns ABC  

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Concatenate

Concatenate Note, when joining two or more fields together, both fields must be a string value. If one of the fields is a numeric value, the numeric field must be converted to a string. SQL Server: SELECT Emp_LastName + ‘,

Tagged with: , , , ,
Posted in Oracle, SQL Server

SQL – Length Function

LENGTH FUNCTION The length function returns an integer value representing the length of the selected field or given value. SQL Server SELECT LEN(‘WORD’) Returns 4 Oracle SELECT LENGTH(‘WORD’) FROM DUAL; Returns 4  

Tagged with: , , , ,
Posted in Oracle, SQL Server