Sample Header Ad - 728x90

How to write an SQL query where the count of 2 different attributes is the same?

3 votes
5 answers
2599 views
I created two different tables and then decided to put them (=) to each other however, what I am confused about is whether (=) is allowed to be used like that. I tried using IN but I didn't know where to go from there either. Is what I did correct? Consider a relational schema for storing information related to movies: ActorMovie(a_name, a_YofB, m_title, m_year) Movie(title, year, genre, budget, cost, gross_earnings) Q: List the names of all actors who acted in an equal number of comedies and tragedies.
Create View V1 AS (
Select 		name
	From 		ActorMovie a, Movie m
Where 		a.m_title = m.title AND a.m_year = m. year AND Genre = ‘Comedy’)

Create View V2 (
Select 		name
	From 		ActorMovie a, Movie m
Where 		a.m_title = m.title AND a.m_year = m. year AND Genre = 
‘Tragedies’)

Select 		COUNT (name) = (Select 	Count (name) FROM 	V2)
From  		V1
Asked by sara khalil (39 rep)
Dec 5, 2023, 03:00 AM
Last activity: Dec 6, 2023, 01:09 PM