This will do it ...

SELECT txt, SUM(num)
from table
where date between '01/01/2003' AND  '12/12/2004' 
group by txt










 

-----Original Message-----
From: Paul Johnston [mailto:[EMAIL PROTECTED] 
Sent: 17 February 2004 15:51
To: [EMAIL PROTECTED]
Subject: [ cf-dev ] Half asleep SQL

Ok... I'm really not in the mood for trying to figure out this sql right
now.  I know it's simple, but I just can't get my head round it!

I have a table with these types of values:

Txt     num     date
A       12      12/02/04
A       44      13/02/04
B       2       13/02/04
B       4       14/02/04
B       9       15/02/04

You get the idea. It's basically a table full of the counts of a string for
a specific day (data collection app).

I want to produce a table for a given date range that says:

Date range, from 12/02/04 to 13/02/04:

Txt     num
A       56
B       2

Anyone do it in one query (NOTE: 1 query). There are 1000s of records for
each day, so doing a

SELECT DISTINCT txt
FROM tbl

And then looping over them to get the:

SELECT COUNT(num)
FROM tbl
WHERE txt = '#myquery.txt#'

Isnt' going to be worthwhile. I know I'm 80% of the way there... Call it
brain fuzz today.

Anyone?

Paul
--------------------------
Paul Johnston
PJ Net Solutions Ltd
E: [EMAIL PROTECTED]
M: +44 7866 573013



--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] For human
help, e-mail: [EMAIL PROTECTED]
This e-mail is from Reed Exhibitions (Oriel House, 26 The Quadrant,
Richmond, Surrey, TW9 1DL, United Kingdom), a division of Reed Business,
Registered in England, Number 678540.  It contains information which is
confidential and may also be privileged.  It is for the exclusive use of the
intended recipient(s).  If you are not the intended recipient(s) please note
that any form of distribution, copying or use of this communication or the
information in it is strictly prohibited and may be unlawful.  If you have
received this communication in error please return it to the sender or call
our switchboard on +44 (0) 20 89107910.  The opinions expressed within this
communication are not necessarily those expressed by Reed Exhibitions.
Visit our website at http://www.reedexpo.com

-- 
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]

Reply via email to