Query - 06-16-2004 , 01:31 AM
If I have R(a integer PRIMARY KEY, b text, c text, d integer); and I
want to find how many different entries there are, (specified using b
and c instead of a), is "select count(distinct b||c) from R" an
appropriate query? Also, if I want to find how many of those that have
a different "d", can I use "select count(d) from R goup by title ||
author"? What if b and c are integers, then I wouldn't be able to
concatenate the 2 fields right?
Re: Query - 06-16-2004 , 01:14 PM
dayzman (AT) hotmail (DOT) com (Michael) wrote in message news:<48e30213.0406152231.6e19331c (AT) posting (DOT) google.com>...
(BTW, I personally hate the DISTINCT keyword, mainly because it is so
Here are some things to think about:
Note 1: concatenating two text fields can bring incorrect results,
imagine these values for your query:
your query, as written considers those two rows the same. Are they the
same? (depends on your application! your answer may be YES.)
Note 2: where did the "title" and "author" attributes come from?? IOW,
if you are making an example, be consistent within the example.
Note 3: Why would changing b and c to integers make a difference to
the LOGIC of the query? Isn't 123 a character string?
I'm not trying to hassle you. Just trying to help you Think it
Re: Query - 06-16-2004 , 03:35 PM
"Michael" <dayzman (AT) hotmail (DOT) com> wrote
select count(1) from
(select distinct b, c from R);
However, your prof may not like this answer.