Wrox Programmer Forums
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 25th, 2007, 04:52 AM
Authorized User
 
Join Date: Oct 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to count?

Hi,

I've these following table,

ipts
npp | name
--------------------------------
A134 | James Computer Centre
A212 | Johnny Tuition

course
courseid | npp | coursename | coursegroup
----------------------------------------------
1 | A134 | Ms Word | Microsoft
2 | A134 | Windows XP | Microsoft
3 | A134 | MySQL 5.0 | MySQL AB
4 | A212 | Windows XP | Microsoft
5 | A212 | Oracle 10g | Oracle Corp
6 | A212 | Oracle Dev | Oracle Corp

How to query - 'how many IPTS carry that coursegroup?', then resut as below:-

coursegroup | NoOfIPTS
----------------------------
Microsoft | 2
MySQL AB | 1
Oracle Corp | 1

please help me.

 
Old February 26th, 2007, 03:13 AM
Authorized User
 
Join Date: Sep 2003
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to prabodh_mishra
Default

Select coursegroup, count(*) NoOfIPTS
From course INNER JOIN ipts On course.npp = ipts.npp
Group By coursegroup

Cheers,
Prabodh
 
Old February 26th, 2007, 11:57 AM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Since you only want to count each IPTS once, try using the following query:

SELECT CourseGroup, COUNT(NPP) AS NPPCount
FROM (SELECT DISTINCT CourseGroup, NPP
FROM Course) A
GROUP BY CourseGroup

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSL: Count = Count + 1 elayaraja.s XSLT 3 July 18th, 2008 03:21 AM
is there any in built function to count page count g.tamilselvan MySQL 1 February 15th, 2006 07:43 AM
Need Count Help ~Bean~ SQL Language 11 August 9th, 2005 11:22 PM
Count, sum, count a value, return records CongoGrey Access 1 April 18th, 2005 02:25 PM
count() crmpicco MySQL 1 January 28th, 2005 01:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.