troubleshooting Question

SQL Query with an inner query?

Avatar of uswebpro9
uswebpro9Flag for Czechia asked on
Microsoft SQL ServerDatabases
1 Comment1 Solution865 ViewsLast Modified:
Hello, I have one SQL statement. (See Fig 1) I use this to make a view. I have another SQL statement (see fig 2) to group by the order dates.
Is there a way to combine both statements into one?

Below is something I tried, with no luck. thanks 4 any help.
SELECT [orderDate]
      ,sum([DailyRevenue]) as DailyRevenue
      ,count([TotalOrders]) as TotalOrders
  FROM (
	dbo.DateOnly(dbo.v_SalesPerEvent.orderDate) AS orderDate, 
	SUM(dbo.v_SalesPerEvent.PricePaid) AS DailyRevenue, 
	COUNT(dbo.v_SalesPerEvent.OrderNumber) AS TotalOrders, 
	dbo.v_SalesPerEvent.ShowId, dbo.tb_Show.Title
FROM         dbo.v_SalesPerEvent INNER JOIN
                      dbo.tb_Show ON dbo.v_SalesPerEvent.ShowId = dbo.tb_Show.showId
GROUP BY dbo.v_SalesPerEvent.ShowId, dbo.v_SalesPerEvent.orderDate, dbo.tb_Show.Title
group by [orderDate],[ShowId],[Title]
order by [orderDate]

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros