Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Sql flight 1
CREATE TABLE flights_table(visitor CHAR(3), DATE INT) INSERT INTO flights_table VALUES ('A', 1); INSERT INTO flights_table VALUES ('B', 1); INSERT INTO flights_table VALUES ('C', 1); INSERT INTO flights_table VALUES ('C', 2); INSERT INTO flights_table VALUES ('D', 2); INSERT INTO flights_table VALUES ('D', 3); INSERT INTO flights_table VALUES ('E', 3); INSERT INTO flights_table VALUES ('A', 4); INSERT INTO flights_table VALUES ('E', 4); INSERT INTO flights_table VALUES ('F', 4); SELECT Date, COUNT(DISTINCT visitor) AS total_visitor, COUNT(DISTINCT visitor) - LAG(COUNT(DISTINCT visitor)) OVER (ORDER BY Date) AS visitor_change FROM flights_table GROUP BY Date ORDER BY Date; SELECT date, SUM(CASE WHEN date = first_date THEN 1 ELSE 0) AS total_new_visitors FROM( SELECT date, MIN(Date) OVER(PARTITION BY visitor) AS first_date FROM flights_table)t GROUP BY date ORDER BY date;
run
|
edit
|
history
|
help
0
Ejercicios de SQL (I)9
MY SQL
EXP 8 q2
manual app locks
First Query
SQL HW 1 Appline
InsertData.sql
remove duplicated rows
SQL_leetcode
estructura