ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  SQL Subqueries
Subject:   Subqueries question - multiple conditions
Date:   2005-01-26 01:24:57
From:   S-P-A-R-K
Hi,


I'd trying to make a grouped query that returns a count of unique values but where I have 2 boolean parameters:


For example - I have an "ID" column, and another boolean column named uType of 1 and 2.
I want to display the count of unique IDs of the 2 kinds (1,2) in 2 different columns.


The table has these fields:
ID | uType("1" or "2")


The result is sort of this:


ID Unique 1 Unique 2
6454 4 3
9788 9 7
9977 5 5
101 8 6


I only can show it in 2 queries and I need to make it one....


SELECT ID, COUNT(DISTINCT ID) AS UniqueID FROM MyTable WHERE uType = 1 GROUP BY ID


Thanks in advance!!!


1 to 2 of 2
  1. Subqueries question - multiple conditions
    2006-12-10 21:24:50  chandu_sql [View]

  2. Subqueries question - multiple conditions
    2005-03-07 07:37:33  edsel99 [View]

1 to 2 of 2