tasks a project management tool keeps data in the sql

Solutions on MaxInterview for tasks a project management tool keeps data in the sql by the best coders in the world

showing results for - "tasks a project management tool keeps data in the sql"
Gaia
14 Sep 2018
1	/*
2A project management tool keeps data in the following two tables: TABLE emp ...
3*/
4
5Create table employee3 (
6id int not null Primary key,
7name nvarchar(50) not null)
8
9drop table if exists tasks
10create table tasks (
11id int not null primary key,
12auhtoiId int not null REFERENCEs EMPLOYEE3(id),
13assigneeId int REFERENCEs EMPLOYEE3(id)
14)
15
16insert into employee3(id, name) 
17			values (1,'Richard'),
18				(2, 'Lily')
19
20insert into tasks(id, auhtoiId, assigneeId) 
21			values (1,1, NULL),
22			(2,2,1)
23-- Write a query that selects task id, author name and assignee name for easch task
24-- If there is no assignee for a task, the query should return NULL 
25-- instead of assign name
26select * from employee3;
27select * from tasks;
28
29Select t.id as 'Task Id', 
30	(Select e1.name 
31		from employee3 e1
32		where e1.id = t.auhtoiId) as 'Auther Name' ,
33	(Select e2.name 
34		from employee3 e2
35		where e2.id = t.assigneeId) as 'Assigne Name'
36	from tasks t
37