sql - How to calculate amount based on the number of working days from the month -


I have the following question that displays the table with date (month) and an amount:

  SELECT TOP 1000 [date], [zodiac] from [database]. [Dbo]. [Table]  

which displays the following:

  Date amount 201304 1750359,95 201305 1853203,29 201306 1741522,66 201307 1655812,14  

I have the following query that gives how much workings (business) days are doing in this month:

  announcement @theDate DATETIME set @theDate = GETDATE ( ) DATA UNION SELECTED DATEADD (MONTH, DateDiff (MONTH, 0, @ the date), 2, as selected from 20 + COUNT (*) (Selection dateADD (MONTH, DateDiff (MONTH, 0, @theDate), 28) 9) Union selection DATEADD (month, DATEDIFF (month, 0, date, 30)) AS DTE date date (day, date) & gt; 28 and DATEDIFF (day, 0, date)% 7 <5>  

To display your table as the following, I would like to query my first query and another query How to add):

  Date amount Average 201304 1750359,95 1750359,95 / 22 = 79561,81 201305 1853203,29 1853203,29/23 = 80574,05 201306 1741522 , 66 ... 201,307 1,655,812.14 ...  

The average amount should be divided by the number of working days for the month.

How can I achieve the average?

pls, try it:

  select top 1000 [Date], [zodiac], [zodiac] / (selection of 20 + COUNT (*) (Selection dateADD (MONTH, DateDiff (MONTH, 0, [date]), 28) TheDate UNION election as DATEADD (MONTH, DateDate (MONTH, 0, [date]), 29) UNION SELECTION DATEADD (MONTH, DateDiff (MONTH, 0, [date]), 30) Where datePart (day, [date])> 28 and DATEDIFF (DAY, 0, [date])% 7 <5) [db] from [database]. [Table]  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -