[thelist] SQL - Group by peculiarity in Sybase

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Thu Apr 14 14:36:21 CDT 2005

> What are you doing in "(necessary filters)"? The only thing that comes
> to mind is that if you are doing some kind of result limiting (like
> MySQL's LIMIT clause), then the database might be incorrectly using
> the table's stored sum in the system catelog. But, if you're offering
> it a date range in the WHERE clause, etc., it shouldn't be using that
> stored value.

nothing special in the where clause no set rowcounts, no limits,
(btw sybase does not support limit at all, it has a set rowcount
directive to deal with it.)

Here is the full query:

SELECT taktar,taktut, sum(taktut) as toplam FROM p_taksit
WHERE taktar between "2005-04-14" and "2005-04-16" 
AND taktut > 0

nothing really special about the where clause as well.
I hadn't given the entire SQL to keep things simple.

> Still, aside from serious deviation in Sybase from SQl standard, I
> don't see us being able to help without seeing the WHERE clause.

The sql is dead simple. That's what makes me conclude that
 there exists such a deviation. However sybase is a well known and
commercial database, so imho it will not deviate from standards this

Have anyone coincided a similar situation? Or am I alone?
Do you think that while the DB tries to "optimize" things, it screws
them up even more.

Does it require all aggragete columns be listed in the group by clause
(when I use group by, I receive a single row again)

What can the reason be?
any ideas? 

I will rtfm carefully (the product is shipped with tons of explanatory
pdf's) I'll inform you if I find anything. In the mean time, your
assistance will be HIGHLY appreciated.
I do not want to lose my brain in this SQL dilemma :)


More information about the thelist mailing list