Hi

can anyone assist in building a matrix in Boost based on sql data queries? Actually:
matrix<double> pricemat(rowCount,colCount);
            for (unsigned i = 0; i < pricemat.size1 (); ++ i)
                for (unsigned j = 0; j < pricemat.size2 (); ++j)
                    pricemat (i, j) = cmd2[3].asDouble();
                    std::cout << pricemat << std::endl;
prints a [221,3] , matching my expectations:
(rowCount =221 & colCount=3) 
However the elements of the matrix are not. Values from cmd2[3].asDouble() are not logically stored as matrix elements for (unsigned i = 0; i < pricemat.size1 (); ++ i) and for (unsigned j = 0; j < pricemat.size2 (); ++j) .
Main issue: since one cannot index cmd2[...].asDouble, the challenge consists of getting in the matrix columns/rows of
pricemat distinct cmd2[3].asDouble() values  for j= 0; j=1, and j=2 and i=0 to 220;
Hope the explanation is clear enough as this is a tricky case




On Sunday, 17 August 2014, 18:59, Ismael Fadiga <ismaeltfadiga@yahoo.co.uk> wrote:


hi all
 
After executing the below sql query in c++, the printed results are:
 
WITH rnum AS (SELECT s.ISN, s.Date, ClosedPrice, row_number() OVER (partition BY s.ISN ORDER BY s.ISN, s.Date DESC) AS rownumber FROM SecurityData s INNER JOIN PortfolioHoldings p ON s.ISN = p.ISN WHERE p.Pfid = 1876) SELECT DISTINCT ISN, Date, ClosedPrice FROM rnum WHERE rownumber <= 250))
 
//ID       Date            Price
US345 2014-08-17 342
US345 2014-08-16 310
...
FR123  2014-08-17  18.20
FR123 2014-08-16   15
 
Does anyone know how to build a price matrix for the IDs like:?
 
          |342  18.20|
MAT=|310   15    |
          |...       ...    |
 
Your feedback would be very appreciated
 
Cheers