Alternative to Derived Tables

  • Consider the following example:

    select a.totalminutes,

    m.memberid,

    m.meetingid

    frommeeting m,

    (select sum(x.minutes) as totalminutes,

    x.meeringid

    frommeeting x

    group by x.meetingid

    ) a

    where a.meetingid = x.meetingid

    memberid could not be included in the group by, so I used a derived table to do the grouping. This works well. However, I had to write the query for mySQL, which does not support derived tables. I solved the problem by summing on the front-end. But could I have written the query in another way to give me all the information that I need?

    Edited by - jxflagg on 01/02/2004 7:49:28 PM

  • If you are asking how to write this query in MySQL, I would post it to their mailing list. MySQL handles some things differently.

    Frank

    http://www.insidesql.de

    http://www.familienzirkus.de

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Thanks Frank. However, I'm really asking, is there a way to write this query without utilizing a derived table.

  • Which version of MySQL are you on?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hm, maybe it's too late or maybe I'm too dumb

    Why is there a GROUP BY in your query?

    May you please explain very slowly your query to me?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Finally it hits me. Forget my last post

    ...but no solution anyway

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 6 posts - 1 through 5 (of 5 total)

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