Unique data in report

  • I have a SQL 2000, 7 database with the following fields

    TagName Char

    Comment Char

    Date Date/Time

    Operator Char

    The TagName field may have one tagname entered several times.

    I want to build a crystal report which will:

    I want to pull data from this database on an ongoing basis.

    List all fields.

    Index on Date, Tag.

    List records with ONLY the latest, unique TagName.

    Not sure how to do this?

    Thanks,

    Randy

  • Maybe:

    SELECT T1.*

    FROM YourTable T1

        JOIN (

            SELECT T2.TagName, MAX(T2.[Date]) AS [Date]

            FROM YourTable T2

            GROUP BY T2.TagName

        ) D ON T1.TagName = D.TagName

                AND T1.[Date] = D.[Date]

    ORDER BY T1.[Date] -- DESC

     

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply