08 Rokon Dbms Home Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Name : Md.

Rokonuzaman Rokon
Roll : 08
Group : B

1. We can find the number of investor of each company by


following the command
select company_name , company_id , count(distinct personID) as
investor_count from Investment group by company_id , company_name;

2. We can find how many capitals of a company .


select company_name , capital from Company ;

3. We can find maximum capital among all the companies.


select max(capital) from Company ;

4. We can find how much money a person invests in the share market .
select Person.personID,Person.name , sum(share) as investment
from Person inner join Investment
on(Person.personID=Investment.personID) group by
Person.personID ;

5. We can find an investor who invests above the particular amount of


money in the share market.
select Person.personID,Person.name ,sum(share) as investment
from Person
inner join Investment on(Person.personID=Investment.personID)
group by Person.personID having investment > 13000;
6. We can find the age of a person using this command
select personID , name , date_of_birth , Gender ,
TIMESTAMPDIFF(YEAR,date_of_birth,CURDATE()) AS Age from
Person where TIMESTAMPDIFF(YEAR , date_of_birth,CURDATE())
between 20 and 50 ;

7. We can create a list of who invests in at least a company .


select Person.personID as investor from Person inner join Investment
on(Person.personID=Investment.personID) group by
Person.personID;

8. We can create a list of who doesn’t invest in any company.


select Person.personID as non_investor from Person left join
Investment on (Person.personID=Investment.personID) group by
Person.personID ,Investment.company_id having
Investment.company_id is null

9. We can find how much money people invest in a company .


select Investment.company_id ,Investment.company_name ,
sum(Investment.share) from Person join Investment on
(Person.personID=Investment.personID) group by
Investment.company_id , Investment.company_name ;

10. Total number of companies .


11. How many people in a family?
12. How many people invest in the share market of a family .
13. How many people don’t invest in the share market of a family .
14. We can find how many people live in the same family .
15. How many investors are in different companies of a particular
family .
16.

You might also like