Solved

Simple current month sales

Posted on 2014-03-18
2
332 Views
Last Modified: 2014-03-18
I have a simple table with orders. I have a OrderAmount field that I want to sum based on the current month. There is also an OrderDate that has a Date and time stamp. Also looking for a ytd summation. I'm trying to avoid making a Calendar Table.
0
Comment
Question by:Southern_Gentleman
2 Comments
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 500 total points
ID: 39938192
Not sure if this is exactly what you're looking for...expected output would be useful.

SELECT
   (
      SELECT SUM(OrderAmount)
      FROM Orders
      WHERE YEAR(OrderDate) = YEAR(GETDATE())
   ) AS YTD,
   (
      SELECT SUM(OrderAmount)
      FROM Orders
      WHERE YEAR(OrderDate) = YEAR(GETDATE())
         AND MONTH(OrderDate) = MONTH(GETDATE())
   ) AS MTD
0
 

Author Closing Comment

by:Southern_Gentleman
ID: 39938244
Cool, Thanks a bunch
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now