–Q.29.Write a query that shows 3 columns. The first indicates which dataset (part 1 or 2) the data comes from,
–the second shows company status, and the third is a count of the number of investors.
SELECT (CASE WHEN companies.permalink IS NOT NULL AND investments.company_permalink IS NULL
THEN 'company_table'
WHEN companies.permalink IS NULL AND investments.company_permalink IS NOT NULL
THEN 'investment_table' END) AS table_source,
companies.status,
COUNT(investments.investor_name)
FROM tutorial.crunchbase_companies companies
FULL JOIN (SELECT *
FROM tutorial.crunchbase_investments_part1 investments_1
UNION ALL
SELECT *
FROM tutorial.crunchbase_investments_part2 investments_2) AS investments
ON companies.permalink = investments.company_permalink
GROUP BY 1,2
ORDER BY 3 DESC
for the question above i am writing the above query, but i am not getting the desired answer
firstly i am confused that in the question “part 1 and 2” refers to investment 1 and investments 2 table or
company and investment_combined tables ,
please also explain how to write case statement with SELECT CLAUSE