Click here to Skip to main content
15,891,136 members
Home / Discussions / Database
   

Database

 
GeneralRe: mysql adding parameters in asp.net vb Pin
Mike Ellison6-May-05 5:10
Mike Ellison6-May-05 5:10 
GeneralRe: mysql adding parameters in asp.net vb Pin
jetset326-May-05 5:19
jetset326-May-05 5:19 
GeneralRe: mysql adding parameters in asp.net vb Pin
Mike Ellison6-May-05 5:37
Mike Ellison6-May-05 5:37 
GeneralRe: mysql adding parameters in asp.net vb Pin
jetset326-May-05 5:46
jetset326-May-05 5:46 
GeneralData export to excel\csv file Pin
mansir 1235-May-05 22:26
mansir 1235-May-05 22:26 
GeneralRe: Data export to excel\csv file Pin
scoroop6-May-05 8:10
scoroop6-May-05 8:10 
GeneralRe: Data export to excel\csv file Pin
S Douglas12-May-05 0:50
professionalS Douglas12-May-05 0:50 
GeneralTwo counts of rows with different criteria Pin
Luis Alonso Ramos5-May-05 19:34
Luis Alonso Ramos5-May-05 19:34 
Hello,

I have a child table that contains rows related to a parent table. I would like, in a single SELECT query for the parent table, to have two counts, one for rows in the child table that match a certain criteria, and another that match some other criteria.

A simple example, a table of Classrooms, with a child table Students, where each student is either male of female; and the query should return ClassroomID, NumMales, and NumFemales.

I can easily get only one count (males for example) using GROUP BY with something like:
SELECT COUNT(StudentID) AS NumMales FROM Students
    GROUP BY Sex WHERE Sex = 0
but I can't find a way to get two different aggregate functions to work on the same table.

In my case it's actually a bit more complicated, because I have three tables related. But a little pointer on how to do it with two tables should help me get started.

Any ideas? Thanks!

-- LuisR



Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!

GeneralRe: Two counts of rows with different criteria Pin
Dan_P5-May-05 19:48
Dan_P5-May-05 19:48 
GeneralRe: Two counts of rows with different criteria Pin
Luis Alonso Ramos5-May-05 20:09
Luis Alonso Ramos5-May-05 20:09 
GeneralSQL Ternary Operator Pin
Syed Abdul Khader5-May-05 19:23
Syed Abdul Khader5-May-05 19:23 
GeneralRe: SQL Ternary Operator Pin
Colin Angus Mackay5-May-05 23:32
Colin Angus Mackay5-May-05 23:32 
GeneralRe: SQL Ternary Operator Pin
Syed Abdul Khader10-May-05 15:54
Syed Abdul Khader10-May-05 15:54 
General"COM object with CLSID {10020200-EB1C-11CF-AE6E-00AA004A34D5} is either not Pin
leezardd5-May-05 9:23
leezardd5-May-05 9:23 
GeneralRe: "COM object with CLSID {10020200-EB1C-11CF-AE6E-00AA004A34D5} is either not Pin
Dan_P5-May-05 20:14
Dan_P5-May-05 20:14 
GeneralRe: "COM object with CLSID {10020200-EB1C-11CF-AE6E-00AA004A34D5} is either not Pin
leezardd12-May-05 3:51
leezardd12-May-05 3:51 
GeneralRunning Store Proc in Access Pin
mjackson115-May-05 7:49
mjackson115-May-05 7:49 
GeneralDatabase logon Pin
Joey Picerno5-May-05 3:53
Joey Picerno5-May-05 3:53 
GeneralNot DataItem Is Nothing == Only true DURING data binding?! Pin
RabidTommy5-May-05 3:29
RabidTommy5-May-05 3:29 
GeneralValidateing values in Stored Procedures Pin
hhrafn5-May-05 0:07
hhrafn5-May-05 0:07 
GeneralRe: Validateing values in Stored Procedures Pin
Colin Angus Mackay5-May-05 0:21
Colin Angus Mackay5-May-05 0:21 
GeneralPlease help me: need sp4 Pin
Chak4-May-05 15:29
Chak4-May-05 15:29 
GeneralRe: Please help me: need sp4 Pin
Colin Angus Mackay4-May-05 19:37
Colin Angus Mackay4-May-05 19:37 
GeneralProb using Oracle 9i Pin
vishalmishra4-May-05 11:46
vishalmishra4-May-05 11:46 
GeneralRe: Prob using Oracle 9i Pin
Colin Angus Mackay4-May-05 12:00
Colin Angus Mackay4-May-05 12:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.