mysql - Query based off one element -


i given following database schema

cows (cowid, cowname, cowage) cowpurchaser (purchaserid, name, address) purchaserecord (purchaserid, cowid, year) 

for each year, cow purchaser "farmland" purchased atleast 1 cow, find number of cows purchased. output set of tuples, indicates year , number of cows purchased "farmland"

i not sure how approach this. tried

select (pr.year, count(c.name)) purchaserecord pr, cowpurchaser cp, cows c cp.name = "farmland" , count(c.name) >= 1 

this not giving result want. doing wrong? how can fix it?

select pr.year, count(c.name) purchaserecord pr      inner join cowpurchaser cp on pr.purchaserid=cp.purchaserid      inner join cows c on pr.cowid=c.cowid cp.name = "farmland"  group pr.year having count(c.name) >= 1 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -