Re: [sqlite] Getting a Unique column from a query

2005-09-30 Thread Dennis Cote

[EMAIL PROTECTED] wrote:


is it possible to use a Distinct or Unique on a column such as:

SELECT school.schoolID AS ID,
CASE WHEN  class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
END AS unique(new_id) FROM Region


SELECT school.schoolID AS ID,
CASE WHEN  class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
END AS distinct(new_id) FROM Region


I do not want any duplicates of the new_id.

Thanks!
Nicole Hinderman


 


I'm not sure what you are trying to do here.

Distinct applies to rows in a result set. A statement like "select 
distinct ..." ensures that each row in the result set is distinct. That 
means that there is a difference in at least one column from every other 
row in the result.


Unique is a constraint that applies to a column, or columns, in a table. 
It ensures that every row in the table has a unique value in that 
column, or combined set of columns.


To help answer your question we will need more information about the 
tables you are using. It looks like you have four, a region table, a 
school table, a class table, and a teacher table. Is that correct?


The query you gave above does not make any sense as it stands. Could you 
explain what you are trying to do in more detail.


Dennis Cote


Re: [sqlite] Getting a Unique column from a query

2005-09-30 Thread njhinder
It would be ok to have duplicates of school_id.  I just want to make sure
that new_id is unique.




   
 Jay Sprenkle  
 <[EMAIL PROTECTED] 
 com>   To 
   sqlite-users@sqlite.org 
 09/30/2005 01:03   cc 
 PM
   Subject 
   Re: [sqlite] Getting a Unique   
 Please respond to column from a query 
 [EMAIL PROTECTED] 
  te.org   
   
   
   
   





Won't you get duplicates rows of school_id, 2
when classtype = 2?

On 9/30/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> is it possible to use a Distinct or Unique on a column such as:
>
> SELECT school.schoolID AS ID,
> CASE WHEN class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
> END AS unique(new_id) FROM Region
>
>
> SELECT school.schoolID AS ID,
> CASE WHEN class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
> END AS distinct(new_id) FROM Region
>
>
> I do not want any duplicates of the new_id.
>
> Thanks!
> Nicole Hinderman
>
>


--
---
The Castles of Dereth Calendar: a tour of the art and architecture of
Asheron's Call
http://www.lulu.com/content/77264




Re: [sqlite] Getting a Unique column from a query

2005-09-30 Thread Jay Sprenkle
Won't you get duplicates rows of school_id, 2
when classtype = 2?

On 9/30/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:
>
> is it possible to use a Distinct or Unique on a column such as:
>
> SELECT school.schoolID AS ID,
> CASE WHEN class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
> END AS unique(new_id) FROM Region
>
>
> SELECT school.schoolID AS ID,
> CASE WHEN class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
> END AS distinct(new_id) FROM Region
>
>
> I do not want any duplicates of the new_id.
>
> Thanks!
> Nicole Hinderman
>
>


--
---
The Castles of Dereth Calendar: a tour of the art and architecture of
Asheron's Call
http://www.lulu.com/content/77264


[sqlite] Getting a Unique column from a query

2005-09-30 Thread njhinder
is it possible to use a Distinct or Unique on a column such as:

SELECT school.schoolID AS ID,
CASE WHEN  class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
END AS unique(new_id) FROM Region


SELECT school.schoolID AS ID,
CASE WHEN  class.classtype= 2 THEN class.classtype ELSE teacher.teacherID
END AS distinct(new_id) FROM Region


I do not want any duplicates of the new_id.

Thanks!
Nicole Hinderman