MySQL group

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

1. SELECT catName, COUNT( title) AS nrOfItems

    FROM categories LEFT JOIN titles ON titles.catid = categories.catid

    GROUP BY catname 

    ORDER BY nrOfItems DESC


2. SELECT title, 

            GROUP_COUCAT( authname ORDER BY authname SEPARATOR ',')

                 AS authors, Lie Ju.

            COUNT ( authors.authID) AS cnt

    FROM authors, titles, rel_title_author

    WHERE authors.authID = rel_title_author.authID

    AND titles.titleID = rel_title_author.titleID

    GROUP BY titles.titleID

    HAVING cnt > 1

    ORDER BY title


3. SELECT langName, catName, COUNT(*)


    FROM titles, languages, categories

    WHERE titles.catID = categories.catID

    AND titles.langID = langueges.langID


    GROUP BY langName, CatName (multi valued packet)


4. SELECT langName, COUNT(*)

    FROM titles, languages

    WHERE titles.langID = langueges.langID

    GROUP BY langName WITH ROLLUP (subtotal, total)





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Wesley at January 18, 2014 - 12:47 PM