Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Shelly1
Starting Member
25 Posts |
Posted - 2009-05-06 : 11:33:02
|
| Hi, i would like to know how to create a Total calculation of ID.select count(ID) as emerg_countHope this makes sense, would be great if someone could helpmany thanksMMich |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2009-05-06 : 12:12:22
|
| This amkes no sense. What calculation would you apply to id? Your current query will basically count the records in the table. Do you want to see how many records are in the table for each ID?How many distinct IDs there are in the table?Jim |
 |
|
|
Shelly1
Starting Member
25 Posts |
Posted - 2009-05-11 : 11:13:18
|
| Hi Yes, i would like to Total the number of distinct IDS there are in the table MMich |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-11 : 11:18:22
|
then it should beselect count(distinct ID) as emerg_count from yourtable |
 |
|
|
Shelly1
Starting Member
25 Posts |
Posted - 2009-05-11 : 11:27:00
|
| Apologies i dont think i am making myself clear, i am trying to TOTAL the count of ID's.e.g: Emerg-Count PCT 10 AAA 12 BBB 15 CCC 16 CCD 17 EEFTotal 70 Mich |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-11 : 11:33:53
|
| select SUM(Emerg-Count) from yourtable |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-11 : 11:37:01
|
and just in case Emerg-Count is derived use thisSELECT SUM([Emerg-Count])FROM(SELECT COUNT(*) AS [Emerg-Count],PCTFROM TableGROUP BY PCT)t |
 |
|
|
|
|
|