Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MAXIMUM SALES

Author  Topic 

Christech82
Starting Member

20 Posts

Posted - 2013-04-10 : 16:07:25
blank

UnemployedInOz
Yak Posting Veteran

54 Posts

Posted - 2013-04-10 : 21:27:43
Looks ok and will work but should be written like

SELECT MODEL, COUNT(SALES_NUM)
FROM SHOE_MODEL JOIN SALES
ON SHOE_MODEL.SHOE_MODEL_NO = SALES. SHOE_MO_NO
GROUP BY MODEL
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-04-11 : 01:12:00
>>the most brand new model shoes that got the maximal number of sales
SELECT TOP 1 WITH TIES MODEL, COUNT(SALES_NUM) MaxSales
FROM SHOE_MODEL JOIN SALES
ON SHOE_MODEL.SHOE_MODEL_NO = SALES. SHOE_MO_NO
GROUP BY MODEL
ORDER BY MaxSales DESC
Go to Top of Page

Christech82
Starting Member

20 Posts

Posted - 2013-04-11 : 15:53:58
quote:
Originally posted by UnemployedInOz

Looks ok and will work but should be written like

SELECT MODEL, COUNT(SALES_NUM)
FROM SHOE_MODEL JOIN SALES
ON SHOE_MODEL.SHOE_MODEL_NO = SALES. SHOE_MO_NO
GROUP BY MODEL



It is working in both ways
Thank you for replying ...
Go to Top of Page
   

- Advertisement -