Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    OK, so far I've tried Ajax query (Will try the other too eventually to compare times) - and it works perfectly. But, now that it came out with a lot more results than expected, I've been given one more requirement: In order to output a row, the date value (col1) must be GREATER than the MINIMUM col1 value for that particular stock. How do you think is the best most optimal way to add that in to the query you already wrote? All I can think of is things that involve a correlated subquery.

  2. #17
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,460
    The requirement is unclear to me - at the moment the query reports where col7 isn't there (so there is not date to compare)

  3. #18
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    The output, though, are rows containing col1 and col7. I would like to only include those rows where the col1 value is greater than the minimum col1 value for the col7 value on the same row.
    Or can also say, eliminate those rows where the col1 value is less than the minimum col1 value for the col7 value on the same row.

    So if a row output is:
    20101015 AAPL
    But in the entire table's data, the minimum col1 value for AAPL (col7) is 20110101, then we want to eliminate this row from the output altogether.

    The reasoning being that it's actually OK if a stock (col7) is missing a date (col1), if the reason is that that stock didn't even exist yet--it's first (minimum) value for col1 is greater than what would be output.

  4. #19
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,460
    This should do what you want
    Code:
    SELECT C.col1, C.col7, D.FirstDate
    FROM ((SELECT col1, col7 FROM (SELECT distinct col1 from table1) as A, (SELECT distinct col7 from table1) as B)  AS C LEFT JOIN Table1 ON (C.col7 = Table1.col7) AND (C.col1 = Table1.col1)) INNER JOIN (SELECT col7, Min(col1) AS FirstDate
    FROM Table1 GROUP BY col7)  AS D ON C.col7 = D.col7
    WHERE (((C.col1)>[FirstDate]) AND ((Table1.col1) Is Null))

  5. #20
    ipisors is offline Access Developer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    119
    This worked perfectly, Ajax. I want to thank both of you profusely, you have helped me a lot. Ajax thanks for bearing with my changes and explanations. This is very helpful.

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums