Skip to content

Instantly share code, notes, and snippets.

@mikebrind
Created August 15, 2018 07:22
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 mikebrind/a261f0778d01dcb09d49862619e8778b to your computer and use it in GitHub Desktop.
Save mikebrind/a261f0778d01dcb09d49862619e8778b to your computer and use it in GitHub Desktop.
create view OrderHeaders as
select c.Name as CustomerName,
o.DateCreated,
sum(oi.Price) as TotalPrice,
count(oi.Price) as TotalItems
from OrderItems oi
inner join Orders o on oi.OrderId = o.OrderId
inner join Customers c on o.CustomerId = c.CustomerId
group by oi.OrderId, c.Name, o.DateCreated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment