Re: [sqlite] Strange behavior with sum

2009-02-08 Thread Alexey Pechnikov
Hello! В сообщении от Sunday 08 February 2009 20:07:14 Dennis Cote написал(а): > Alternatively, if you want to use SQL that is more portable, you could > also cast the result of the SUM function to a floating point value to > ensure that a floating point division is done. > >     sqlite> select

Re: [sqlite] Strange behavior with sum

2009-02-08 Thread Dennis Cote
D. Richard Hipp wrote: > On Jan 29, 2009, at 10:40 AM, matkinson wrote: > > >> Hi, >> >> I'm not replying with an answer, but with a similar problem. I am >> using a >> TRAC database on top of a SQLite DB and I want to provide a >> percentage of >> the sum total hours/sum estimated hours.

Re: [sqlite] Strange behavior with sum

2009-01-29 Thread D. Richard Hipp
On Jan 29, 2009, at 10:40 AM, matkinson wrote: > > Hi, > > I'm not replying with an answer, but with a similar problem. I am > using a > TRAC database on top of a SQLite DB and I want to provide a > percentage of > the sum total hours/sum estimated hours. Here's what I'm seeing. > - when

Re: [sqlite] Strange behavior with sum

2009-01-29 Thread matkinson
Hi, I'm not replying with an answer, but with a similar problem. I am using a TRAC database on top of a SQLite DB and I want to provide a percentage of the sum total hours/sum estimated hours. Here's what I'm seeing. - when only one value (a natural number) is summed and divided, the answer

Re: [sqlite] Strange behavior with sum

2006-06-02 Thread A. Pagaltzis
* Klint Gore <[EMAIL PROTECTED]> [2006-06-02 07:30]: > sqlite> select cast(sum(f1) as double)/cast(sum(f2) as double) from bob; > 0.869779988128673 Just casting one of them is sufficient, btw. Regards, -- Aristotle Pagaltzis //

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Klint Gore
On Thu, 01 Jun 2006 23:08:13 -0500, Kareem Badr <[EMAIL PROTECTED]> wrote: > Does anyone know what's going on here? Is this just user error? It's just integer division. D:\sqlite>sqlite3 :memory: SQLite version 3.3.4 Enter ".help" for instructions sqlite> create table bob (f1 varchar, f2

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Kareem Badr
I tried that, but the fields ended up getting set to '', rather than 0. The fields are defined as varchar, remember. *But*, I don't think the NULL values are causing the problems, because the query runs fine when more than 1 row was returned. And my query actually returned all the rows,

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Bill KING
Kareem Badr wrote: > Bill KING wrote: >> Kareem Badr wrote: >> >>> I should mention that free_space and size are defined as varchars, for >>> some reason. Not sure if that has anything to do with the issues I'm >>> seeing. >>> >>> >> Do any of these fields contain NULL? as that will

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Kareem Badr
Bill KING wrote: Kareem Badr wrote: I should mention that free_space and size are defined as varchars, for some reason. Not sure if that has anything to do with the issues I'm seeing. Do any of these fields contain NULL? as that will definately have an impact upon both joins and upon

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Bill KING
Kareem Badr wrote: > I should mention that free_space and size are defined as varchars, for > some reason. Not sure if that has anything to do with the issues I'm > seeing. > Do any of these fields contain NULL? as that will definately have an impact upon both joins and upon calculations. (when

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Kareem Badr
I should mention that free_space and size are defined as varchars, for some reason. Not sure if that has anything to do with the issues I'm seeing.

Re: [sqlite] Strange behavior with sum

2006-06-01 Thread Kareem Badr
Yet, the following query: SELECT d.name, disks.name, sum(free_space), sum(size) FROM devices d LEFT OUTER JOIN disks ON (d.id=disks.computer_id AND disks.name='G:') WHERE d.name='kensho'; Gives the following result: kensho|G:|206140624896|237003182080 Which I can use to calculate the

[sqlite] Strange behavior with sum

2006-06-01 Thread Kareem Badr
This is probably my own SQL rustiness, but can someone explain this to me? If I run this query: SELECT d.name, disks.name, free_space/size FROM devices d LEFT OUTER JOIN disks ON (d.id=disks.computer_id AND disks.name='G:') WHERE d.name='kensho' ; I get the following result: