Skip to content

Commit 02400bc

Browse files
authored
Add files via upload
1 parent 89f985c commit 02400bc

52 files changed

Lines changed: 263 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ADVANCE JOIN/Placements.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Select S.Name
2+
from Students S inner join Friends f
3+
on S.ID = f.ID
4+
inner join Packages p
5+
on f.ID = p.ID
6+
inner join Packages fp
7+
on f.Friend_ID = fp.ID
8+
where fp.Salary > p.Salary
9+
order by fp.Salary;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Author: @bratinkanrar
2+
SELECT s.Proj_Start_Date, min(e.Proj_End_Date) as Real_Proj_End_Date
3+
FROM
4+
(SELECT Start_Date as Proj_Start_Date FROM Projects WHERE Start_Date NOT IN (SELECT End_Date FROM Projects)) s,
5+
(SELECT End_Date as Proj_End_Date FROM Projects WHERE End_Date NOT IN (SELECT Start_Date FROM Projects)) e
6+
WHERE s.Proj_Start_Date < e.Proj_End_Date
7+
GROUP BY s.Proj_Start_Date
8+
ORDER BY DATEDIFF(min(e.Proj_End_Date), s.Proj_Start_Date) ASC, s.Proj_Start_Date ASC;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Author: Thomas George Thomas
2+
SELECT BT.N,
3+
CASE
4+
WHEN BT.P IS NULL THEN 'Root'
5+
WHEN EXISTS (SELECT B.P FROM BST B WHERE B.P = BT.N) THEN 'Inner'
6+
ELSE 'Leaf'
7+
END
8+
FROM BST AS BT
9+
ORDER BY BT.N

Advanced Select/New Companies.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Author: Thomas George Thomas
2+
SELECT c.company_code,c.founder,
3+
count(distinct lm.lead_manager_code),
4+
count(distinct sm.senior_manager_code),
5+
count(distinct m.manager_code),
6+
count(distinct e.employee_code)
7+
FROM Company c, Lead_Manager lm, Senior_Manager sm, Manager m, Employee e
8+
WHERE
9+
c.company_code=lm.company_code AND
10+
lm.lead_manager_code=sm.lead_manager_code AND
11+
sm.senior_manager_code=m.senior_manager_code AND
12+
m.manager_code=e.manager_code
13+
GROUP BY c.company_code,c.founder
14+
ORDER BY c.company_code ASC

Advanced Select/Occupations.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Contributor: Abhishek Srivastava
2+
SELECT
3+
MAX(CASE WHEN Occupation = 'Doctor' THEN Name END) AS Doctor,
4+
MAX(CASE WHEN Occupation = 'Professor' THEN Name END) AS Professor,
5+
MAX(CASE WHEN Occupation = 'Singer' THEN Name END) AS Singer,
6+
MAX(CASE WHEN Occupation = 'Actor' THEN Name END) AS Actor
7+
FROM (
8+
SELECT
9+
Name,
10+
Occupation,
11+
ROW_NUMBER() OVER (PARTITION BY Occupation ORDER BY Name) AS rn
12+
FROM OCCUPATIONS
13+
) AS sub
14+
GROUP BY rn;
15+

Advanced Select/The PADS.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Author: Thomas George Thomas
2+
select concat(name,'(',substring(Occupation,1,1),')') as Name
3+
from occupations
4+
order by Name;
5+
Select concat ('There are a total of ', count(occupation),' ', lower(occupation),'s.') as totals
6+
from occupations
7+
group by occupation
8+
order by totals
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Author: Thomas George Thomas
2+
Select
3+
CASE
4+
when A + B <= C or A + C <= B or B + C <= A then "Not A Triangle"
5+
when A = B and B = C then "Equilateral"
6+
when A = B or A = C or B = C then "Isosceles"
7+
else "Scalene"
8+
end as triangle_sides
9+
from TRIANGLES

Aggregation/Average Population.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Author: Thomas George Thomas
2+
SELECT FLOOR(AVG(POPULATION))
3+
FROM CITY

Aggregation/Japan Population.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Author: Thomas George Thomas
2+
SELECT SUM(POPULATION)
3+
FROM CITY
4+
WHERE COUNTRYCODE ='JPN'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Author: Thomas George Thomas
2+
SELECT MAX(POPULATION) - MIN(POPULATION)
3+
FROM CITY

0 commit comments

Comments
 (0)