SQLTeam.com | Weblogs | Forums

SQL Query about Select inside another Select

Hi everyone! I am from Brazil and I would like to ask you for some help, if possible. Please, I need a solution about an SQL select statement. I have a database on mysql administrator. I am attaching an illustration with the entity relationship diagram of my database. I need to make a SQL Select query for it to produce the following result:

  1. One table which returns the names of the projects of the employee who earns the smallest salary and the employee who earns the biggest salary.

  2. One table which returns the total number of dependents of the employee who earns the smallest salary and the employee who earns the biggest salary.

I'm sorry if you don't understand my post, but English is not my first language and here in Brazil we don't have enough English lessons. Thank you very much for any answers!

hi

/*

People in this forum are busy and will not have time to do this ...( create sample data)
we want to directly work on the SQL part ...

We can also help you understand how to write SQL ..

Please post sample data ...for your questions
like this ...

drop table #sampledata
go

create table #sampledata
(ts datetime2,
item varchar(20),
sellerid varchar(20)
)
go

insert into #sampledata
values
('2019-09-05 12:02:55.533','b123 ','dfjk'),
('2019-09-03 12:02:55.533','b123 ','TV12'),
('2019-09-03 12:02:55.533','b123 ','uiop')
go

*/

hi

i tried to create the sample data

drop table dbo.project 
go 

create table dbo.project 
(
project_id int, 
project_name varchar(100),
)
go 

drop table dbo.employee
go 

create table dbo.employee
(
employee_id int ,
employee_name varchar(100),
employee_salary int , 
project_id int, 
department_id int 
) 
go 


insert into dbo.project select 1,'project_alpha'
insert into dbo.project select 2,'project_gamma'
insert into dbo.project select 3,'project_cleanup'
insert into dbo.employee select 2222,'har',1000,1,20
insert into dbo.employee select 3345,'pra',2000,2,44
insert into dbo.employee select 3333,'ok', 400 ,3,44
go 
 
select * from dbo.project 
select * from dbo.employee 
go