sql server - How to group projected revenue (same, daily, fixed amount) by month between two dates -
The table I am using is revenue_start_date, total_reven and day and month and revenue group for me . Daily revenue amount is clear (total / rave / day) but I do not know how to group revenue groups monthly.
For example, if a line item starts at 8/25/14 and has a revenue of $ 5,000 for 50 days, then daily income is $ 100, August will total $ 600, September 3, 000 And $ 1,400 will be
I am thinking that I should create a function that includes $ 100 for each day in a temporary table and then asks the table and by a group. Is there a way to insert a cursor without using it?
Using it:
- ===== "Inline "CTE-operated" Tally Table "produces values ranging from 0 to -1000 ... enough VARCHAR (8000) to cover with E1 (N) 1 Select All Union 1 All Select 1 Union Select All 1 Union Select All 1 Union Select All 1 Union Select All 1 Union Select All 1 Union Select All 1 Select Union All 1), --10E + 1 or 10 Rows E2 (N) AS Select 1A, 1B to 1, select --10E + 2 or 100 rows E4 (N) (from 1E2A, E2B), --10A + 4 or maximum rows maximum CTTY (N) AS (- - === It provides "zero base" and limits the number of rows - one performance gain and prevention - accidentally to select "waiver" both above Select Select Select Association ROW_NUMBER () Select (select NULL) from E4), as with DailyRev (Select to Datamem (MM, DateAd (DD, RTDAT, N) dated name (mm, date) as day / day in the form of Daily Revenue, DateAid (DD, RTDAT, N) as DD, StartDate, N from data. Add (DD, Start Size, N)) Select this Math, the sum of money from the Demurveu Group (Daily Revenue);
The use of Tally tail (or number table) is used to allocate total revenue from the initial date to the initial date + 1 day + 1. At the same time calculate the appropriate month for each of those days. Query by a simple group then produces monthly grouped total revenue amount.
Comments
Post a Comment