sort (union tables) desc

  • Hi,

    Iam doing 4 tables union and descending order by 2 fields.

    Here is sample query

    Select * from (

    Select equipno,activitydate,activitytime from Table1

    Union all

    Select equipno,activitydate,activitytime from Table2

    Union all

    Select equipno,activitydate,activitytime from Table3

    Union all

    Select equipno,activitydate,activitytime from Table4

    ) as k Order by Activitydate,activitytime desc

    But result is coming in Ascending order. If order by one field its giving correct result.

    What is the problem.

    Thanks

    Vishal

  • Run this.

    Select * from (

    Select equipno,activitydate,activitytime from Table1

    Union all

    Select equipno,activitydate,activitytime from Table2

    Union all

    Select equipno,activitydate,activitytime from Table3

    Union all

    Select equipno,activitydate,activitytime from Table4

    ) as k Order by Activitydate desc ,activitytime desc

  • Thank you allen,

    Its working

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

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