Home Forums SQL Server 7,2000 T-SQL T-SQL Equivalent to MS Access'' "First" function RE: T-SQL Equivalent to MS Access'''' "First" function

  • The problem with this is that you have min(column1) and group by Column1.  Think about it.  This query is identical to (Select column1 from table1 group by Column1).

    Try

    SELECT Column1, column2

    from table1 tmain

    inner join

    (SELECT column1, min(ID) as minID from table1 group BY Column1) a tfirst

    on tmain.column1 = tfirst.column1 and ID = minID

    The following order by column3:

    Select t.column1, t.column2

    from table1 t

    inner join

    (select min(ID) as ID, column1, MinColumn3

     from table1 ttop

      inner join (select column1, min(column3) as MinColumn3

        from table1 group by column1) tmin

    on tmin.column1 = ttop.column1 and MinColumn3 = Column3

    group by column1, MinColumn3

    ) tfirst

    on t.ID = tfirst.ID and t.Column1 = tfirst.Column1 and MinColumn3 = Column3

    Russel Loski, MCSE Business Intelligence, Data Platform