Recreating TD functions in normal SQL - sql

I’ve been using rank(), row_number() and dense_rank() in Teradata SQL for quite sometime and have had to transition across to an older version of SQL, without these functions.
Is there a way to recreate these functions easily? I’m currently using a proc sql; in SAS-EG. I’m aware of SAS being able to use first. and last function but there must be a way to do it solely in SQL?
I’m aware of the monontonic() function but have yet to be able to reset it where I want my partition to end/able to create a dense_rank with it.
Any help would be greatly appreciated

RANK, ROW_NUMBER and DENSE_RANK are all window functions in MySQL-8.0. Just update to this version and they will be there.

Related

BigQuery - Increment Values aside from the Windowed Functions

Is there another way to assign incremental values on a column without using the Windowed Function Row_Number() and Rank() in Google BigQuery.
Im actually encountering resource problems when using these functions
Thanks for the answer

Search the position of a column in SQLite

I am searching... and I don't find how can I find in SQlite what is the position of an item in the column.
When i use ROW_NUMBER() i get:
ERROR: near "(": syntax error (code 1)
SELECT Nom ROW_NUMBER () OVER (ORDER BY Score) AS Rownumber
FROM tableau
I'm using MIT App Inventor with Taifun extension sqlite
Other question how to know which item is in position 2 (or another number) in the column?
This is too long for a comment.
ROW_NUMBER() is an ANSI-standard function. However, not all databases use it. For instance, SQLite, MySQL, and MS Access (among others) do not support this functionality.
Presumably, you are using one of these database that does not support this function.
I would suggest that you research what database you are using. Then, try investigating how to implement the functionality you want using that database. If you can't figure out how, ask another question, providing sample data, desired results, and a tag for the database you are using.
If this is indeed the code you are running:
SELECT Nom ROW_NUMBER () OVER (ORDER BY Score) AS Rownumber FROM tableau
Then what is Nom? This is a syntax error in practically every implementation. What you are probably looking to do is:
SELECT Nom, ROW_NUMBER () OVER (ORDER BY Score) AS Rownumber FROM tableau
Notice the comma after Nom.

HIVE:: How To Mimic SQL Server Table-Value Function

I am really new to the hive space and am learning as we go. Anyway, currently I am using a SQL Server Table function that accepts several input parameters and returns a table of dates (invoicedate,duedate).
For example, i would pass in ('2017-01-01',12,30,3) (date, duration, terms,interval) and the output would be something like:
'2017-01-01','2017-02-01'
'2017-04-01','2017-05-01'
'2017-09-01','2017-10-01'
'2017-10-01','2018-01-01'
First, is this feasible to do within the hive environment? And second, if so, I'm thinking the UDTF would be the method. If anyone has any thoughts or can point me to an online example they have seen, i would be greatly appreciative.
What you want is a UDTF:
https://cwiki.apache.org/confluence/display/Hive/DeveloperGuide+UDTF
.................................

SAP HANA Calculate percentage in a script calculation view

I was wondering if there was a way to achieve this kind of aggregation :
In practice: using (I think) CE_AGGREGATION how is possible to create a percentage formula like the one in "calculated column"?
I try a lot of combination (CE_PROJECTION,CE_AGGREGATION, CE_CALC...) but no ones of them works.
This because it seems that the script do a kind of sum(A/b*100), but I would like to obtain sum(a)/sum(b)*100. In graphical mode is instead very simple!
Someone has an idea about how to reproduce that?
Really, don't bother using the CE_-functions anymore.
Use SQL instead.
This is not only much easier but also SAP HANA has more options to rewrite and optimize the statements internally.
This should then lead to more options for better performance.
Anyhow, to do calculations like that, there is the CE_CALC function, that you can use within a CE_PROJECTION function.
Again: stop using CE_-functions. SQL is King!

How to pass an entire row (in SQL, not PL/SQL) to a stored function?

I am having the following (pretty simple) problem. I would like to write an (Oracle) SQL query, roughly like the following:
SELECT count(*), MyFunc(MyTable.*)
FROM MyTable
GROUP BY MyFunc(MyTable.*)
Within PL/SQL, one can use a RECORD type (and/or %ROWTYPE), but to my knowledge, these tools are not available within SQL. The function expects the complete row, however. What can I do to pass the entire row to the stored function?
Thanks!
Don't think you can.
Either create the function with all the arguments you need, or pass the id of the row and do a SELECT within the function.