473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem with COUNT

139 100+
Hi,

I have a table showing a persons skill in any particular application. So there are 4 columns of skills - Access, CF, HTML, SQL and numerous rows of people names and a check if they have that skill.

This is then output to a webpage showing the same checkboxes.

I want to show a count of the number of people who have that skill at the bottom of the column.

I can do this for each skill:

Expand|Select|Wrap|Line Numbers
  1. <cfquery datasource="taskbook" name="GetGMC" maxrows="1">
  2. select        count(GeoMedia) as GeoMediaCount
  3. from        tblSkillBase
  4. group by    GeoMedia
  5. </cfquery>
  6.  
and output the query result at the bottom of the row, but I've have to write 4 queries, which seems really inefficient.

Is there any way to write just one query, that counts the number of checks in a column, and produces a sum for each one?

I'm using ancient Coldfusion MX by the way!
Thanks
Neil
Oct 6 '10 #1
3 2128
acoder
16,027 Expert Mod 8TB
You can add the GeoMedia field and get back counts for each:
Expand|Select|Wrap|Line Numbers
  1. select GeoMedia, count(*) as ...
Oct 6 '10 #2
ndeeley
139 100+
Hi acoder,

I have tried that, and grouped the query by all the columns, but CF doesn't return the count for each column:

Expand|Select|Wrap|Line Numbers
  1. <cfquery datasource="taskbook" name="GetGMC" maxrows="1">
  2. select        GeoMedia, count (*) as GeoMediaCount,
  3.         Strumap, count (*) as StrumapCount
  4. from        tblSkillBase
  5. group by    GeoMedia, Strumap
  6. </cfquery>
  7.  
..it just returns a value of 1. Do I need to loop over the query in my results set?

Thanks for your help!
Neil
Oct 7 '10 #3
acoder
16,027 Expert Mod 8TB
Right, I assumed that the skills were in one column. So they're in 4 separate columns? In that case, you can use a variation of the latest query, but with 1 count. This will give you counts of those that have each skill alone and those that have a combination and you can tot up the totals.

If that's not the solution, can you give some examples of what each field contains.
Oct 8 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Kong Li | last post by:
Follow up to this thread, the latest Oracle 9i release 2 patchset (9.2.0.5) fixed the handle count leak problem. The problem is in Oracle client component. Thanks. Kong ----- From: Kong...
8
by: Sowen | last post by:
Hi, I have an object "elem", there are only simple functions inside, like setName, getName, and three constructors Now I have another class "Base", need an array of elem to initialize class...
1
by: Rohit Raghuwanshi | last post by:
Hello all, we are running a delphi application with DB2 V8.01 which is causing deadlocks when rows are being inserted into a table. Attaching the Event Monitor Log (DEADLOCKS WITH DETAILS) here....
4
by: Jeffrey Barrett | last post by:
Can someone tell me why I'm having this problem: When I select drink 5 and deposit too little money, there's a problem with the 'difference' variable. Try to deposit $.80 instead of the full $.85...
47
by: fb | last post by:
Hi Everyone. Thanks for the help with the qudratic equation problem...I didn't think about actually doing the math...whoops. Anyway... I'm having some trouble getting the following program to...
4
by: MrL8Knight | last post by:
Hello, I am trying to build a simple php form based shopping cart using a cookie with arrays. I need to use 1 cookie because each order will have over 20 items. With that said, I realize I need to...
52
by: celerysoup16 | last post by:
I've written this coin toss program, and can't figure out why it isn't giving accurate results... cheers, Ben #include <stdlib.h> #include <stdio.h> #define H 1 #define T 0 #define SENTINEL...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
4
by: haresh.amis | last post by:
hello to all, I m using .net 2.0 and i face a problem that is as under Well I have a checkboxlist which i bound in .cs page now I want to count that how many checkboxes ate checked ( In...
5
by: Chad | last post by:
say my input file is $ more suck ______ < gnu? > ------ \ , , \ /( )` \ \ \___ / | /- _ `-/ '
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.