Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 14, 2019 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/9e9fc3cd19d76642cc968f5889108f0c to your computer and use it in GitHub Desktop.
Save parzibyte/9e9fc3cd19d76642cc968f5889108f0c to your computer and use it in GitHub Desktop.
/*El producto más vendido*/
select top 1 pp.ProductID, pp.Name, count(ss.ProductID) as veces_vendido
from Production.Product pp
inner join Sales.SalesOrderDetail ss
on pp.ProductID = ss.ProductID
group by ss.ProductID, pp.Name, pp.ProductID
order by count(ss.ProductID) desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment