Thanks.  Yes, that works.

----- Original Message ----- From: <[EMAIL PROTECTED]>
To: <sqlite-users@sqlite.org>
Sent: Saturday, May 05, 2007 9:37 PM
Subject: Re: [sqlite] Getting a list of items on a column


"jose isaias cabrera" <[EMAIL PROTECTED]> writes:

"C.Peachment" wrote,


On Sat, 5 May 2007 19:58:19 -0400, jose isaias cabrera wrote:


Greetings!

imagine this data content,

c1, c2, c3
a, 1, 2
b, 3, 4
c, 5, 6
a, 9, 8
a, 1, 9
c, 1, 3

I would like to get a list of all the items in c1. So, the return would be,

a,
b,
c

I know how to do it programmatically, but is there a way to get it right
from SQLite?

select distinct c1 from tablename;

Thanks.

Ok, I am going to push my luck. :-) Imagine the same data, what if I wanted to get the sum of the other two columns also? I know how to do it one at a
time, so in this instance I would have to do 3 separate call using sum or
total, but is there a way that I could do it on the same call and get the sum
of columns c2 and c3, so that I would get something like this,

a,11,19
b,3,4
c,6,9

Yes, I know.  I am pushing my luck. :-)

How about something like

 SELECT c1, SUM(c2), SUM(c3)
   FROM tablename
   GROUP BY c1;

Cheers,

Derrell

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------



-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to