>Description: A column of the SELECT-part of a query returns allways NULL in some cases. This seems to happen when using a "GROUP BY" and computing on some parts of the SELECT. >How-To-Repeat: create table users_table (id integer primary key not null auto_increment, gender varchar(1)); insert into users_table values(NULL, 'M'); insert into users_table values(NULL, 'F'); insert into users_table values(NULL, 'F'); insert into users_table values(NULL, 'F'); insert into users_table values(NULL, 'M'); create table log_table (user_id integer not null, timestamp datetime); insert into log_table values (1, SYSDATE()); insert into log_table values (2, SYSDATE()); insert into log_table values (1, SYSDATE()); insert into log_table values (3, SYSDATE()); insert into log_table values (4, SYSDATE()); insert into log_table values (4, SYSDATE()); SELECT u.gender AS gender, count(DISTINCT u.id) AS dist_count, (count(DISTINCT u.id)/5*100) AS percentage FROM users_table u, log_table l WHERE l.user_id = u.id GROUP BY u.gender ORDER BY percentage;
>Fix: It seems to be a problem when inserting NULL values in the auto_increment-column of table users_table. When inserting real values instead of NULL-values everything works just fine. Executing a slightly modified SELECT-statement solves the problem too: SELECT concat(u.gender, '') AS gender, count(DISTINCT u.id) AS dist_count, (count(DISTINCT u.id)/5*100) AS percentage FROM users_table u, log_table l WHERE l.user_id = u.id GROUP BY u.gender ORDER BY percentage; >Submitter-Id: <submitter ID> >Originator: Niek Kerkemeijer >Organization: Web Power BV >MySQL support: none >Synopsis: A column of the SELECT-part of a query returns allways NULL in some >cases. >Severity: non-critical >Priority: medium >Category: mysql >Class: sw-bug >Release: mysql-3.23.49a (Official MySQL RPM) >Environment: System: Linux hp.office.webpower.nl 2.2.16-22smp #1 SMP Tue Aug 22 16:39:21 EDT 2000 i686 unknown Architecture: i686 Some paths: /usr/bin/perl /usr/bin/make /usr/bin/gmake /usr/bin/gcc /usr/bin/cc GCC: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs gcc version 2.96 20000731 (Red Hat Linux 7.0) Compilation info: CC='gcc' CFLAGS='-O6 -fno-omit-frame-pointer -mpentium' CXX='gcc' CXXFLAGS='-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' LDFLAGS='' LIBC: lrwxrwxrwx 1 root root 14 Apr 2 2001 /lib/libc.so.6 -> libc-2.1.92.so -rwxr-xr-x 1 root root 4776568 Aug 30 2000 /lib/libc-2.1.92.so -rw-r--r-- 1 root root 22607104 Aug 30 2000 /usr/lib/libc.a -rw-r--r-- 1 root root 178 Aug 30 2000 /usr/lib/libc.so Configure command: ./configure --disable-shared --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-other-libc=/usr/local/mysql-glibc --without-berkeley-db --without-innodb --enable-assembler --enable-local-infile --with-mysqld-user=mysql --with-unix-socket-path=/var/lib/mysql/mysql.sock --prefix=/ --with-extra-charsets=complex --exec-prefix=/usr --libexecdir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var/lib/mysql --infodir=/usr/info --includedir=/usr/include --mandir=/usr/man '--with-comment=Official MySQL RPM' CC=gcc 'CFLAGS=-O6 -fno-omit-frame-pointer -mpentium' 'CXXFLAGS=-O6 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti -mpentium' CXX=gcc --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php