안녕 나는 다음과 같은 쿼리를 작성하고 그 결과 내가 필요하지 않은 변경되었을 때에 가입실행이 값을 기준으로 그룹이
제 1
select case_PrimaryCompanyId as companyid, CONVERT(VARCHAR(7),ca.case_createddate, 111) AS Date, 'Moving Balance' as InvoiceType, sum(mb.Amount) as Amount from cases as ca
제 2
left join ( select case_PrimaryCompanyId as companyid, case_createdDate, case_TotalExVat as Amount from cases ) mb on ca. case_primaryCompanyId = mb.companyid and ca.case_createdDate >= mb.case_CreatedDate where ca.case_primaryCompanyId = companyid group by case_primaryCompanyId, CONVERT(VARCHAR(7),ca.case_createddate, 111)
좋아요. 위의 데이터 목록을 다음과 같이 그룹화하고 월 및 연도별로 그룹화하고 amoun을 집계합니다. 시간의 시작부터.
Date Actual Amount 20/10/2009 1766.52 07/11/2009 2778.02 14/01/2010 -2700.00 28/02/2010 -78.02 27/05/2010 2489.40 27/05/2010 2491.20 30/05/2010 2494.80
모든 것이 완벽하게 작동하여 매달마다 cummlative 값을 계산합니다.
내가 될 때까지 행 (2010.05.09 후 이동 대차 대신 한번의 5 월 (대신 회만의 그룹 값이 변경 될 때)
Moving Balance Result Date Displays Should be 2009/10 1766.52 1766.52 2009/11 2788.02 2788.02 2010/01 78.02 78.02 2010/02 0.00 0.00 2010/05 22426.20 7475.50
시도 가질 수의 각 레코드 합계 계산 별개의 mb.Amount)하지만 어떤 아이디어가 정말 레이첼
감사 을 감상 할 수있다나던 작업
SQL Server를 사용하고있는 것 같습니다. 어떤 버전입니까? – podiluska