on 11-23-2012 5:30 AM
Hi All,
I need to write an SQL in HANA, which would produce a similar result to an NTILE() in SQL 2008.
as per my knowledge NTILE function does not exist in HANA SQL. Has anybody written an SQL similar to this function?
e.g below the MSSQL 2008 code, which need to be re-written in HANA SQL.
select case when FLD1 in ('AA','XX')
then 'BB'
else FLD1 end as FLD1,
NTILE(3) Over (PARTITION by case when FLD1 in
('AA','XX') then 'BB'
else FLD1 end
Order by FLD_Dis Asc) as Percentile,
FLD_Dis,
'ALL' as FLD2,
'ALL' as FLD3,
From
"SCHEMA"."TABLE1"
where FLD2 >= 10
GROUP BY FLD3, FLD1, FLD2,FLD_Dis
Order by 1,2,3,4;
Thanks
Ranjit
Hello Ranjit,
no idea what your timeframe is, but window functions (like NTILE, SUM, RANK, LAG/LEAD...) are being developed and will find their ways into HANA standard.
So maybe it pays to wait for this.
However, I can't tell when these functions will be available.
Cheers,
Lars
ADDITIONAL INFORMATION:
Just had a look into the current SQL reference manual which is already out for SPS5: http://help.sap.com/hana/html/_esql_functions_window.html
As you see, window functions will be available on a HANA system near you soon 😉
Message was edited by: Lars Breddemann
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please look into the official HANA documentation on window functions:
Window Functions - SAP HANA SQL and System Views Reference - SAP Library
NTILE and RANK are available.
BRs,
Lucas de Oliveira
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.