I'm having a really hard time trying to figure out how to make the following search:

"Find the sellers specialized in selling cars of the year (They can only sell cars produced during a specific year, example 2010).

The tables I have are:

Seller: {Seller_Id, Name, City_Residence}
Business: {Car_Id,Seller_Id,Year_car_Produced, Business_Date, Price}
Car: {Car_Id, Model, Brand, Country, Table_Price}

I was thinking about doing a DISTINCT for the Year_car_Produced but that doesn't mean the Seller couldn't sell cars in different years. I would only get the different cars he sold per year.

Can someone help me?

I'd really appreciate it.

Recommended Answers

All 6 Replies

Your requirement seems quiet contradicting to me.

Post requirement clearly, what exactly you want.

I want to find the name of the Seller who sell cars only during a specific year.
For example, I have three sellers:

John - John sold two cars (no matter the model), one in 2007 and another in 2008.
Gary - Gary sold three cars (no matter the model), all in 2009
Peter - Peter sold one car in 2010

After the SQL search only the names of Gary and Peter would show up in the results since they were the only ones who were sold cars during a single year, 2009 for Gary and 2010 for Peter.

In that case you need to join the tables Seller and Business on Seller_Id and filter by Year_car_Produced.

In that case you need to join the tables Seller and Business on Seller_Id and filter by Year_car_Produced.

That would be possible if I was working with static values.
I don't know the years included in the table so I can't say:

Select s.name, s.Year_car_Produced from Sellers s, Car c, Bussiness b
Where s.Seller_id = b.Seller_id and b.Car_Id = c.Car_Id
Group By s.Year_car_Produced

Convert the piece of SQL code into a stored function and pass the year as parameter.

Never mind.
I thank you for all the help but I realized there is no need to work over this anymore.

Thanks debasisdas

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.