Jump to content

SQL help

Go to solution Solved by myselfolli,

For future reference:

 

SELECT
	CustomerId,
   	YEAR(Date),
    MONTH(Date),
    SUM(Order_Numbers)
FROM Tabelle
GROUP BY CustomerId, YEAR(Date), MONTH(Date);

 

Okay, so this is probably really simple and I'm just not seeing the solution, but here's my problem:

 

I have a table in which there are order numbers from a day by day basis:

 

-------------------------------------------------------------

| CustomerId | Date            | Order_Numbers |

-------------------------------------------------------------

| 1234            | 2018-12-03 | 10.000                |

-------------------------------------------------------------

| 1234            | 2018-12-04 | 15.000                |

-------------------------------------------------------------

| 1234            | 2018-11-27  | 5.000                 |

-------------------------------------------------------------

 

I have to wirte a query to find out, how many orders there were in total for a give month and customer. Selecting the customer and Month is easy, but I cannot figure out how to get the sum of the order_numbers for the month in question...

Any ideas?

75% of what I say is sarcastic

 

So is the rest probably

Link to comment
https://linustechtips.com/topic/1004344-sql-help/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×