• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help me to understand the coding

sql = "SELECT left(Extract.[Lgl Port Code],4) as Expr1, Sum(Extract.[Sum Curr Book Val Amt]) AS Book, Sum(Extract.[Sum Curr Mkt Val Amt]) AS Mkt, Sum(Extract.[sum Functional Face Shr Amt]) AS Par " & _"FROM Extract GROUP BY left(Extract.[Lgl Port Code],4) ORDER BY left(Extract.[Lgl Port Code],4)"

--------------------------------------------------------------------------------

Port = Cells(intCounter, 1)
----------------------------------------------------------------------------

Loop Until Port = rs("Expr1").Value
---------------------------------------------------------------------------
 
The first line is building an SQL statement. SQL's use a particular format to choose what data they want, from which columns, using specific conditions. I recommend reading this article (or some of the related ones) as it looks like you've been asked to deal with a lot of SQL.
http://www.sqlcourse.com/select.html

Note that there are vriable within the statement being built by the SUMS of other data.
----------
The middle statements cells that the Port variable is equal to the Cells found in row intCounter, column A. So, if IntCounter = 3, this says to make Port = cell A3.

-----
Perform a loop until Port is equal the to Expr1 parameter of rs.
 
Back
Top