The background,

SQL_ERROR_INFO: ‘Every Derived table must have its own alias’

from( select user_id,row_number() over(partition by user_id order by user_id) as re, Lead (date,1,0) over(partition by user_id order by user_id) as lo from login) where re=2;Copy the code

Second, find the cause

Error statement SQL_ERROR_INFO: ‘Every Derived table must have its own alias’, which translates to Every derived table must have its own alias.

This is an error when performing a multi-table query, or when subquerying a newly created table if the new table is not aliased. So you just need to give the new table a different name

Iii. Solutions

Alias the new table!

from( select user_id,row_number() over(partition by user_id order by user_id) as re, Lead (date,1,0) over(partition by user_id order by user_id) as lo from login) as newtable Where newtable. Re = 2;Copy the code