August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!
DECLARE @totalOrderCount INT BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. --SET NOCOUNT ON; SET @totalOrderCount = (SELECT COUNT(o.orders_id) FROM orders O WHERE o.orders_status = 4 AND DATEDIFF(DAY, o.date_purchased, GETDATE()) < 31) SELECT COUNT(o.orders_id) AS ordercount, (DATEDIFF(DAY, o.date_purchased, osh.orders_status_history_timestamp)) AS timetaken, (COUNT(o.orders_id) / @totalOrderCount) AS orderPC, @totalOrderCount AS orderTotal FROM orders O, dbo.tblPS_orders_status_history OSH WHERE o.orders_status = 4
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.