205k views
1 vote
Write a SQL query to find the population of the planet named 'Caprica' -- 10 points Find the first name, last name, and age of people from bsg_people whose last name is not 'Adama' -- 10 points Find the name and population of the planets with a population larger than 2,600,000,000 -- 10 points Find the first name, last name, and age of people from bsg_people whose age is NULL -- 12 points

User ArunMKumar
by
3.8k points

2 Answers

4 votes

Answer:

SQL Query : select population from bsg_planets where name='Caprica';

SQL Query : select fname,lname,age from bsg_people where lname!='Adama';

SQL Query : select name,population from bsg_planets where population > 2600000000;

SQL Query : select fname,lname,age from bsg_people where age='NULL';

Step-by-step explanation:

using MySQL Workbench.

SQL Query : select population from bsg_planets where name='Caprica';

Because this sql query will return the population from bsg_planets where the name is Caprica;

SQL Query : select fname,lname,age from bsg_people where lname!='Adama';

Because this SQL query will return the first name ,last name and age from the bsg_people where last name is not adama.

SQL Query : select name,population from bsg_planets where population > 2600000000;

Because this SQL query will return the name and population where population is greater than 2600000000

SQL Query : select fname,lname,age from bsg_people where age='NULL';

Because this SQL query will return the first name ,last name and age from the bsg_people where age is NULL.

User VincenzoC
by
3.2k points
2 votes

The question is incomplete! Complete question along with answer and step by step explanation is provided below.

Please find the attached question.

Answer:

a) SQL Query:

SELECT population

FROM bsg_planets

WHERE name='Caprica';

b) SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE lname!='Adama';

c) SQL Query:

SELECT name, population

FROM bsg_planets

WHERE population > 2600000000

d) SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE age IS NULL;

Step-by-step explanation:

a) Write a SQL query to find the population of the planet named 'Caprica'

Syntax:

SELECT Column

FROM TableName

WHERE Condition;

For the given case,

Column = population

TableName = bsg_planets

Condition = name='Caprica'

SQL Query:

SELECT population

FROM bsg_planets

WHERE name='Caprica';

Therefore, the above SQL query finds the population of the planet named 'Caprica' from the table bsg_planets.

b) Find the first name, last name, and age of people from bsg_people whose last name is not 'Adama'

Syntax:

SELECT Column1, Column2, Column3

FROM TableName

WHERE Condition;

For the given case,

Column1 = fname

Column2 = lname

Column3 = age

TableName = bsg_people

Condition = lname!='Adama'

SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE lname!='Adama';

Therefore, the above SQL query finds the first name, last name and age of people whose last name is not 'Adama' from the table bsg_people.

c) Find the name and population of the planets with a population larger than 2,600,000,000

Syntax:

SELECT Column1, Column2

FROM TableName

WHERE Condition;

For the given case,

Column1 = name

Column2 = population

TableName = bsg_planets

Condition = population > 2600000000

SQL Query:

SELECT name, population

FROM bsg_planets

WHERE population > 2600000000

Therefore, the above SQL query finds the name and population of the planets with a population larger than 2,600,000,000 from the table bsg_planets.

d) Find the first name, last name, and age of people from bsg_people whose age is NULL

Syntax:

SELECT Column1, Column2, Column3

FROM TableName

WHERE Condition;

For the given case,

Column1 = fname

Column2 = lname

Column3 = age

TableName = bsg_people

Condition = age IS NULL

SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE age IS NULL;

Therefore, the above SQL query finds the first name, last name and age of people whose age is NULL from the table bsg_people.

Write a SQL query to find the population of the planet named 'Caprica' -- 10 points-example-1
User Cannyboy
by
3.2k points