Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 4 additions & 44 deletions solution/1400-1499/1435.Create a Session Bar Chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,53 +70,13 @@ Sessions 表:
### **SQL**

```sql
(
SELECT
'[0-5>' AS bin,
SUM(
CASE
WHEN duration / 60 < 5 THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[0-5>' AS bin, count(1) AS total FROM Sessions WHERE duration < 300
UNION
(
SELECT
'[5-10>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 5 AND duration / 60 < 10) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[5-10>' AS bin, count(1) AS total FROM Sessions WHERE 300 <= duration AND duration < 600
UNION
(
SELECT
'[10-15>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 10 AND duration / 60 < 15) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[10-15>' AS bin, count(1) AS total FROM Sessions WHERE 600 <= duration AND duration < 900
UNION
(
SELECT
'15 or more' AS bin,
SUM(
CASE
WHEN duration / 60 >= 15 THEN 1
ELSE 0
END
) AS total
FROM Sessions
);
SELECT '15 or more' AS bin, count(1) AS total FROM Sessions WHERE 900 <= duration;
```

<!-- tabs:end -->
48 changes: 4 additions & 44 deletions solution/1400-1499/1435.Create a Session Bar Chart/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,53 +65,13 @@ For session_id 5 has a duration greater than or equal to 15 minutes.
### **SQL**

```sql
(
SELECT
'[0-5>' AS bin,
SUM(
CASE
WHEN duration / 60 < 5 THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[0-5>' AS bin, count(1) AS total FROM Sessions WHERE duration < 300
UNION
(
SELECT
'[5-10>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 5 AND duration / 60 < 10) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[5-10>' AS bin, count(1) AS total FROM Sessions WHERE 300 <= duration AND duration < 600
UNION
(
SELECT
'[10-15>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 10 AND duration / 60 < 15) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[10-15>' AS bin, count(1) AS total FROM Sessions WHERE 600 <= duration AND duration < 900
UNION
(
SELECT
'15 or more' AS bin,
SUM(
CASE
WHEN duration / 60 >= 15 THEN 1
ELSE 0
END
) AS total
FROM Sessions
);
SELECT '15 or more' AS bin, count(1) AS total FROM Sessions WHERE 900 <= duration;
```

<!-- tabs:end -->
48 changes: 4 additions & 44 deletions solution/1400-1499/1435.Create a Session Bar Chart/Solution.sql
Original file line number Diff line number Diff line change
@@ -1,47 +1,7 @@
(
SELECT
'[0-5>' AS bin,
SUM(
CASE
WHEN duration / 60 < 5 THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[0-5>' AS bin, count(1) AS total FROM Sessions WHERE duration < 300
UNION
(
SELECT
'[5-10>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 5 AND duration / 60 < 10) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[5-10>' AS bin, count(1) AS total FROM Sessions WHERE 300 <= duration AND duration < 600
UNION
(
SELECT
'[10-15>' AS bin,
SUM(
CASE
WHEN (duration / 60 >= 10 AND duration / 60 < 15) THEN 1
ELSE 0
END
) AS total
FROM Sessions
)
SELECT '[10-15>' AS bin, count(1) AS total FROM Sessions WHERE 600 <= duration AND duration < 900
UNION
(
SELECT
'15 or more' AS bin,
SUM(
CASE
WHEN duration / 60 >= 15 THEN 1
ELSE 0
END
) AS total
FROM Sessions
);
SELECT '15 or more' AS bin, count(1) AS total FROM Sessions WHERE 900 <= duration;