Results 1 to 3 of 3

Thread: SQL help still

  1. #1
    chagood@angelfire.com Guest

    SQL help still

    I am trying to write an sql statement which would return the most recent
    row (determined by max(identity) based on the uniqueness of the composite of three columns. The example below explain this better. I am having the devil of a time combining the distinct logic and the max identity to return all
    column values.


    |.........uniqueness.....|
    tb1.col1 tb2.col1 tb3.col1 tb4.col1 tb4.col2 tb4.identity
    a a a 11 22 1
    a a a 12 34 2 -- return this row
    a b a 13 64 3 -- return this row
    a c b 14 65 4
    a c b 15 69 5 -- return this row

  2. #2
    Gregory Guest

    SQL help still (reply)

    something like this?:

    select distinct
    tb1.col1
    tb2.col1
    tb3.col1
    from .....
    where tb4.identity = (select max() from...)


    ------------
    chagood@angelfire.com at 5/19/99 12:03:19 PM

    I am trying to write an sql statement which would return the most recent
    row (determined by max(identity) based on the uniqueness of the composite of three columns. The example below explain this better. I am having the devil of a time combining the distinct logic and the max identity to return all
    column values.


    |.........uniqueness.....|
    tb1.col1 tb2.col1 tb3.col1 tb4.col1 tb4.col2 tb4.identity
    a a a 11 22 1
    a a a 12 34 2 -- return this row
    a b a 13 64 3 -- return this row
    a c b 14 65 4
    a c b 15 69 5 -- return this row

  3. #3
    Guest

    SQL help still (reply)

    Thanks, but
    That will return the correct latest tb1.col1, tb2.col1, tb3.col2
    but how do I get tb4.col1, tb4.col2 and tb4 identity? They would be associated with the maximum tb4 identity row. Obviously, there is a
    portion of the where clause that is not shown that tb4 with columns of the other tables.

    ------------
    Gregory at 5/19/99 2:03:34 PM

    something like this?:

    select distinct
    tb1.col1
    tb2.col1
    tb3.col1
    from .....
    where tb4.identity = (select max() from...)


    ------------
    chagood@angelfire.com at 5/19/99 12:03:19 PM

    I am trying to write an sql statement which would return the most recent
    row (determined by max(identity) based on the uniqueness of the composite of three columns. The example below explain this better. I am having the devil of a time combining the distinct logic and the max identity to return all
    column values.


    |.........uniqueness.....|
    tb1.col1 tb2.col1 tb3.col1 tb4.col1 tb4.col2 tb4.identity
    a a a 11 22 1
    a a a 12 34 2 -- return this row
    a b a 13 64 3 -- return this row
    a c b 14 65 4
    a c b 15 69 5 -- return this row

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •