Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit bf5e444

Browse files
committed
Adding Solutions
1 parent 99df532 commit bf5e444

18 files changed

+119
-1
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Leetcode SQL Questions & Solutions <br/>
22
#### Repository Contains :<br/>
33

4-
(1) 160+ Leetcode SQL Question Solutions<br/>
4+
(1) 190+ Leetcode SQL Question Solutions<br/>
55
(2) PostgreSQL Dump File (leetcodedb.sql)<br/>
66

77
#### Problem statements of all questions including leetcode premium questions :<br/>

‎dump_file/leetcodedb.sql

876 Bytes
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT v.customer_id,COUNT(v.visit_id)
2+
FROM visits_1581 v
3+
LEFT JOIN transactions_1581 t ON v.visit_id = t.visit_id
4+
WHERE t.transaction_id IS NULL
5+
GROUP BY v.customer_id
6+
ORDER BY v.customer_id;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT u.name,SUM(t.amount)
2+
FROM transactions_1587 t
3+
INNER JOIN users_1587 u ON t.account=u.account
4+
GROUP BY u.name
5+
HAVING SUM(t.amount) > 10000
6+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT seller_name
2+
FROM seller_1607
3+
WHERE seller_id NOT IN
4+
(SELECT DISTINCT seller_id
5+
FROM orders_1607
6+
WHERE EXTRACT(YEAR FROM sale_date) = 2020);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT a.student_name,b.student_name,c.student_name
2+
FROM school_a_1623 a
3+
CROSS JOIN school_b_1623 b
4+
CROSS JOIN school_c_1623 c
5+
WHERE a.student_id <> b.student_id AND a.student_id <> c.student_id AND b.student_id <> c.student_id AND
6+
a.student_name <> b.student_name AND a.student_name <> c.student_name AND b.student_name <> c.student_name;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
SELECT contest_id,ROUND((COUNT(DISTINCT user_id)*100.0)/user_count.cnt,2) AS percentage
2+
FROM register_1633
3+
CROSS JOIN (SELECT COUNT(*) AS cnt FROM users_1633) user_count
4+
GROUP BY contest_id,user_count.cnt
5+
ORDER BY percentage DESC,contest_id;
6+
7+
--OR--
8+
9+
SELECT contest_id,ROUND((COUNT(DISTINCT user_id)*100.0)/(SELECT COUNT(*) AS cnt FROM users_1633),2) AS percentage
10+
FROM register_1633
11+
GROUP BY contest_id
12+
ORDER BY percentage DESC,contest_id;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
SELECT s.machine_id,ROUND(AVG(e.timestamp-s.timestamp)::NUMERIC,3) AS processing_time
2+
FROM activity_1661 s
3+
INNER JOIN activity_1661 e
4+
ON s.activity_type = 'start' AND e.activity_type = 'end' AND
5+
s.machine_id = e.machine_id AND s.process_id = e.process_id
6+
GROUP BY s.machine_id;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SELECT user_id,INITCAP(name)
2+
FROM users_1667
3+
ORDER BY user_id;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
SELECT p.name,SUM(i.rest) AS rest,SUM(i.paid) AS paid,SUM(i.canceled) AS canceled,SUM(i.refunded) AS refunded
2+
FROM invoice_1677 i
3+
INNER JOIN product_1677 p ON i.product_id = p.product_id
4+
GROUP BY p.name
5+
ORDER BY p.name;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /