Top "Window-functions" questions

A window function is a type of SQL operation that aggregates over a partition of the result set.

Calculating SQL Server ROW_NUMBER() OVER() for a derived table

In some other databases (e.g. DB2, or Oracle with ROWNUM), I can omit the ORDER BY clause in a …

sql sql-server tsql window-functions ranking-functions
Dynamic alternative to pivot with CASE and GROUP BY

I have a table that looks like this: id feh bar 1 10 A 2 20 A 3 3 B 4 4 B 5 5 C 6 6 D 7 7 D 8 8 D And …

sql postgresql pivot crosstab window-functions
Spark Window Functions - rangeBetween dates

I am having a Spark SQL DataFrame with data and what I'm trying to get is all the rows preceding …

sql apache-spark pyspark apache-spark-sql window-functions
Best way to get result count before LIMIT was applied

When paging through data that comes from a DB, you need to know how many pages there will be to …

php sql postgresql window-functions sql-limit
Error: invalid input syntax for integer: ""

I have this table tbl_buku: id_buku judul_buku tahun_buku 1 Bioogi 2010 2 Fisika 2010 3 Informatika 2012 4 Kimia 2012 I use query like …

sql postgresql null string window-functions
How to make a SUM without group by

Here is my problem.. Actual Auction Ammanat id 7000 500 100 228,229 7000 100 100 228,229 7000 900 100 228,229 5000 0 0 230 I want result as given below Actual Auction Ammanat Remaining id 7000 500 100 5550 228,229 7000 100 100 5550 228,229 7000 900 100 5550 228,229 5000 0 0 5000 230 Here, …

sql sql-server postgresql window-functions
Count distinct values with OVER(PARTITION BY id)

Is it possible to count distinct values in conjunction with window functions like OVER(PARTITION BY id)? Currently my query …

postgresql window-functions
spark sql window function lag

I am looking at the window slide function for a Spark DataFrame in Scala. I have a DataFrame with columns …

scala apache-spark window-functions
ROW_NUMBER( ) OVER in impala

I have a use case where I need to use ROW_NUMBER() over PARTITION: Something like: SELECT Column1 , Column 2 ROW_…

sql window-functions impala
Getting the First and Last Row Using ROW_NUMBER and PARTITION BY

Sample Input Name | Value | Timestamp -----|-------|----------------- One | 1 | 2016-01-01 02:00 Two | 3 | 2016-01-01 03:00 One | 2 | 2016-01-02 02:00 Two | 4 | 2016-01-03 04:00 …

sql sql-server tsql window-functions row-number