TIGER ANALYTICS INTERVIEW QUESTION | Return Lag Num columns without row number

Question: Return 2 columns, Number and lag_num. Lag_num should be the prev value as per the way the data is inserted

DML Script: 

DROP TABLE IF EXISTS Numbers;


CREATE TABLE Numbers (number INT);

INSERT INTO Numbers (number) VALUES (1), (2), (3), (7), (6), (8), (9), (13), (10);


 SELECT * FROM Numbers

Comments

Popular posts from this blog

50 Essential SQL Questions to Land Your Dream Job

How to find all the customers who placed orders on three consecutive days | SQL Scenario questions

ACCENTURE SQL INTERVIEW QUESTION | Change the ProductIDs