Alternate Queries?

  • Hi,

    I've this query ...can we have some alternate to the repeating query ..as in t1 and t2

     

    select * from

    (

     select

     month(thedate) monthnum,count(*) rows

     from table1

     where sid='7106' and year(thedate)=2005 and ename like '%mathews%'

     group by  month(thedate)

    ) as t1

     where t1.rows=(select max(rows) from

    (

    select

     month(thedate) monthnum,count(*) rows

     from table1

     where sid='7106' and year(thedate)=2005 and ename like '%mathews%'

     group by  month(thedate)

    ) as t2

    )

  •  select top 1 month(thedate) monthnum,count(*) rows

     from table1

     where sid='7106' and year(thedate)=2005 and ename like '%mathews%'

     group by  month(thedate)

     order by 2 desc

    Regards,
    gova

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

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