Click here to Skip to main content
15,868,016 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi everyone please help me
i have a database design like this :

https://ars.els-cdn.com/content/image/3-s2.0-B978012385126000019X-f19-07-9780123851260.jpg

What I have tried:

so I want to know how to get the result for below question:
1/what is the name of the product that have lowest sale this month?
2/what is the name of the state that have lowest sale this year?
3/what is the name of the product that have best sale this year?
Posted
Updated 4-Jan-20 21:52pm
Comments
Dave Kreskowiak 4-Jan-20 14:35pm    
So, are you looking for someone to do your homework for you?
Member 14707064 4-Jan-20 15:24pm    
no i'm not , i just have final research so i need those for my research its not my homework .... thanks
PIEBALDconsult 4-Jan-20 21:49pm    
That's homework.
Mike Hankey 4-Jan-20 15:02pm    
Here's a start

https://www.w3schools.com/sql/sql_select.asp
Member 14707064 4-Jan-20 15:25pm    
thank you so much for your help....

In a Short: you have to use Aggregate Functions (Transact-SQL)[^]

I'm bit lazy today (as it's a sunday) and i don't want to analyze your database diagram, so... general tip:

To get the quantity of products:
SQL
SELECT Product, COUNT(*) AS Quantity
FROM SaleTable
GROUP BY Product


To get the value of sale:
SQL
SELECT Product, SUM(Price) AS TotalSale
FROM SaleTable
GROUP BY Product
 
Share this answer
 
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.
 
Share this answer
 
Comments
Member 14707064 4-Jan-20 15:34pm    
thanks for your answer.. i know what you said but i have final research so i need those for complete a part of my works , i try to do that by myself but i don't know how do that its a reason that i posted it in here ............. thanks
OriginalGriff 4-Jan-20 15:55pm    
If you tried it yourself, then show what you tried, explain what it did that you didn't expect or or didn't do that you did expect, tell us what you tried to work out why, and what help you need.

Just posting your homework question doesn't get you anywhere here!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900