Re: [sqlite] newbie question regarding my sqlite code

2009-01-10 Thread Emil Obermayr
Am Samstag, 10. Januar 2009 schrieb silvio grosso:

> The query is:
> select avg(age), avg(durata), sum(età) from acoda, main, dipendenti

This is "cross join" over all three tables. The result is a "monster table", 
consisting of every possible combination of the records of those three 
tables. And in this "monster table" the sum most probably is correct.

Please read your SQL-documention about different types of joins and what they 
are good for.

For debugging purposes you can have a look at 

  select *  from acoda, main, dipendenti

to see the raw result of your join.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] newbie question regarding my sqlite code

2009-01-10 Thread RB Smissaert
Try this:

select
avg(age)
from acoda
union all
select
avg(durata)
from main
union all
select
sum(età)
from dipendenti


RBS


-Original Message-
From: sqlite-users-boun...@sqlite.org
[mailto:sqlite-users-boun...@sqlite.org] On Behalf Of silvio grosso
Sent: 10 January 2009 10:41
To: sqlite-users@sqlite.org
Subject: [sqlite] newbie question regarding my sqlite code

Hello,

I am a new sqilte user and I am learning sqlite code in my spare time..
I have always used sql code with Microsoft Access and Base (openoffice).
Therefore, sorry to ask a question very simple .

When I write the very simple code:
select sum(età) from dipendenti
everything works fine and the result is 100.

When
I try a bit longer query the result for the sum regarding the column
età from the table dipendenti changes and it is wrong. That is 25200?
(instead of the right value 100!).

The query is:
select avg(age), avg(durata), sum(età) from acoda, main, dipendenti

In
the above query the avg results for the column age (table acoda) and
the column durata (table main) are right. The only value wrong is the
third, that it, sum (for the table dipendenti, column age, 25200 instead of
the right value 100).
The column age in the table dipendenti is not present in the other two
tables (acoda, main).

What's wrong with the second query?


Thanks in advance.

Best regards



  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] newbie question regarding my sqlite code

2009-01-10 Thread silvio grosso
Hello,

I am a new sqilte user and I am learning sqlite code in my spare time..
I have always used sql code with Microsoft Access and Base (openoffice). 
Therefore, sorry to ask a question very simple .

When I write the very simple code:
select sum(età) from dipendenti
everything works fine and the result is 100.

When
I try a bit longer query the result for the sum regarding the column
età from the table dipendenti changes and it is wrong. That is 25200?
(instead of the right value 100!).

The query is:
select avg(age), avg(durata), sum(età) from acoda, main, dipendenti

In
the above query the avg results for the column age (table acoda) and
the column durata (table main) are right. The only value wrong is the
third, that it, sum (for the table dipendenti, column age, 25200 instead of the 
right value 100).
The column age in the table dipendenti is not present in the other two tables 
(acoda, main).

What's wrong with the second query?


Thanks in advance.

Best regards



  
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users