Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Samuel Gendler
On Fri, Feb 11, 2011 at 12:47 PM, Aaron Burnett wrote: > > > Thank you all very much for your help. > > The suggestion from Osvaldo below was the best for my situation (not having > any soret of xref table to join)... > > It may work well for now, but if that foo_activity table has the potential

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Aaron Burnett
Thank you all very much for your help. The suggestion from Osvaldo below was the best for my situation (not having any soret of xref table to join)... Best Regards, Aaron On 2/11/11 1:09 PM, "Osvaldo Kussama" wrote: 2011/2/11, Aaron Burnett : > > Hi, > > I'm just drawing a blank entirely

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Osvaldo Kussama
2011/2/11, Aaron Burnett : > > Hi, > > I'm just drawing a blank entirely today and would appreciate some help on > this. > > The long and short; there are 12 distinct activities that need to be queried > on a weekly basis: > > SELECT count(activity_id), activity_id > FROM foo_activity > WHERE creat

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Samuel Gendler
Assuming you have a table which lists all possible activities, with one activity per row and no duplicates, you need to do a left outer join between activities and your query result. That will generate a resultset that has at least one row for every row in activities, with nulls in all the columns

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Rob Sargent
On 02/11/2011 11:46 AM, Aaron Burnett wrote: > > Hi, > > I'm just drawing a blank entirely today and would appreciate some help on > this. > > The long and short; there are 12 distinct activities that need to be queried > on a weekly basis: > > SELECT count(activity_id), activity_id > FROM fo

Re: [SQL] Drawing a blank on some SQL

2011-02-11 Thread Peter Steinheuser
Not tested. 1. select count(t2.activity_id), t1.activity_id from (select distinct activity_id from foo_activity) as t1, -- assumes all activities exist somewhere in table left join foo_activity t2 on (t1.activity_id = t2.activity_id) WHERE created >= '01/01/2011' and created < '01/08/20

[SQL] Drawing a blank on some SQL

2011-02-11 Thread Aaron Burnett
Hi, I'm just drawing a blank entirely today and would appreciate some help on this. The long and short; there are 12 distinct activities that need to be queried on a weekly basis: SELECT count(activity_id), activity_id FROM foo_activity WHERE created >= '01/01/2011' and created < '01/08/2011'

Re: [SQL] DELETE FROM takes forever

2011-02-11 Thread Hiltibidal, Rob
Even DB2 and Oracle will take hellishly long times to perform large scale deletes What I do for a database just under 300 gb in size is do deletes in groups of 10,000 So your where clause might look some like WHERE id NOT IN (SELECT id FROM unique_records fetch first 1 rows only) DB2