Sunteți pe pagina 1din 2

SQL server Netezza equivalent functions

** As Netezza is case sensitive be careful with String comparison (best practice to use upper/lower case
when comparing string columns both the sides) this applicable for joining group by as well.
The exception is when one wants to find a specific string (ex: - I want to search only NeteZZA in my
column).


Sno SQL Server Functions Netezza Functions Purpose of the function
SUBSTRING(CASE_NO,
PATINDEX('%[^0 ]%',
CASE_NO+ ' '), LEN(CASE_NO))
ltrim(CASENUMBER,'0')

Remove left hand side zeros from case
number
RTRIM (CASENUMBER,'0')
EX:- RTRIM (0011124500,'0')
Result:- 00111245

Remove right hand side zeros from case
number
LEFT() substr()
EX:- substr(VAMSHI,0,3)
Result VA

When we want only LEFT had side last 3
digits or charades
RIGHT() substr('VAMSHI',LENGTH('VAMSHI')-
1)

RESULT:- HI
Formula for last 2 alphabets do
Length -1
For 3 its length -2
For 4 its Length -3
Use when we need Right hand side digits
or charades
CONVERT(VARCHAR(10),
DATE_FLD, 101)
TO_CHAR(RECIEVEDATE,'DD/MM/YYYY') To convert date to the format we want
Ex:- 'DD/MM/YYYY' or DD/MON/YYYY
etc.,
Like Function Like The LIKE function syntax and
functionality is same to SQL server
Case Function Case The CASE function syntax and
functionality is same to SQL server
DATE FUNCTION (For numeric result)
Year(RCV_DAY_DAY_DT) extract(year from RCV_DAY_DAY_DT)

This give us the year
EX:- 2014
MOTH(RCV_DAY_DAY_DT) extract(MOTH from RCV_DAY_DAY_DT)

This give us the year
EX:- 1(JAN)
DAY(RecieveDate) extract(DAY from current_date) This give us day of the year
EX:- 14(day of the year)
extract(WEEK from current_date) Week of the year
EX:- its 38 week of this year 2014
DATE FUNCTION (For String result)
to_char(DATE_D,'DAY')

EX:- WEDNESDAY
to_char(DATE_D,'Month')

EX:- September
Adding months days and to get QUARTER out of DATE
SELECT EXTRACT(QUARTER FROM
now());
To get the quarter from DATE
months_between(d1, d2) To get the months between 2 dates
age(t,t) To get the difference between to dates
last_day(now()) To get the last day of the month
add_months(now(),-1)) To Add or subtract a month to the date






First 10 records or Top 100 records

TOP 1
LIMIT 1 It limits the no of records we want to see
LIMIT 2 OFFSET 2
Ex:-
SELECT * FROM TABLE ORDER BY
CASENUMBER LIMIT 2 OFFSET 2
Offset will skip the first 2 records and
limit will give 3 and 4 records

**Order by is key for these functions
select get_value_varchar(array_split('dl_v5.2_2_9_1200_256_0_1_64_0_54_2345','_') ,
5);

S-ar putea să vă placă și