I am having problems with a SQL query, i need a list of consumers having purchased at least 3 different products whose suppliers are from a certain city (Lets say new york).
Tabels Columns:
Tb_Consumer..........Con_ID(PK), Name, City
Tb_Supplier.............Supp_ID(PK), Name, City
Tb_Transactions.....Tran_ID(PK), Supp_ID(FK), Con_ID(FK), PROD_ID(FK)
Tb_Products............Prod(ID(PK), Name
What i have so far:
var query8Result = (from c in context.Tb_Consumer
join t in context.Tb_Transactions on c.Con_ID equals t.Con_ID
join s in context.Tb_Supplier on t.Supp_ID equals s.Supp_ID
join p in context.Tb_Product on t.Prod_ID equals p.Prod_ID
where s.City == "New York"
select new { Name = c.Name }).Distinct();