Results 1 to 2 of 2

Thread: query help

  1. #1
    Join Date
    Apr 2004
    Posts
    101

    Unanswered: query help

    Hi there,

    I have a query which returns count of particular type. And i need to get the all count types total at the bottom.
    here is the query
    SELECT a.Type, COUNT(DISTINCT b.ID)
    FROM emp a
    LEFT OUTER JOIN dept b
    ON b.Name LIKE '%.' + a.Type
    GROUP BY a.Type

    and here is the sample result set.

    DOC 214
    exe 1

    And i wanted to include a row say Total

    I wanted to see the result set like this

    DOC 214
    exe 1

    Total 215


    Any help is greatly appreciated.
    Thanks in advance.

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Code:
    SELECT SUM(COUNT_ID) 
      FROM	(
    	  SELECT a.Type, COUNT(DISTINCT b.ID) AS COUNT_ID 
    	    FROM emp a 
           LEFT JOIN dept b 
    	      ON b.Name LIKE '%.' + a.Type 
    	GROUP BY a.Type
    	) AS XXX
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •