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

SVG stroke-linecap doesn't work for circles in Firefox? -

routes - Laravel 4 Wildcard Routing to Different Controllers -

cross browser - XSLT namespace-alias Not Working in Firefox or Chrome -