• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 138
  • Last Modified:

Getting the sum of portfolios by half years.

I have the following table:

PortfolioId             CUSIP                        Issue Date               CurrentAmount
---------------        -----------------            --------------------        --------------------
1                             123456XYZ                  3/2/2005                $1,000,000
1                             987654ABC                2/25/2005                $2,000,000
1                             111111XXX                7/25/2005                $3,000,000
2                             222222XXX                6/25/2006                $2,500,000  etc.

Is there a way in SQL to get the sum of each half (per portfolio).  In the example above, the sum of the first half of 2005 is $1,000,000 + $2,000,000 = $3,000,000 (for portfolio 1).  The sum of the second half for portfolio 1 is $3,000,000, etc.
0
James Cochrane
Asked:
James Cochrane
1 Solution
 
James CochraneB2B FINTECH WRITER/Technology WriterAuthor Commented:
Further, I need to have all the years accounted for not just one year and sorted by the half year,

i.e., 1st Half 2005 comes before 2nd Half 2005, etc.

Thanks
0
 
ryndyeCommented:
try

Select Year(IssueDate), Ceiling(Month(IssueDate)/6), ProtfolioId,  , ,
  From Table
 Group By Year(IssueDate), Ceiling(Month(IssueDate)/6), PortfolioId
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now