473,395 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

removing rows that meet certain aggregate criteria

I have a database like this:

host | search term | number of searches
abc.com | "blah" | 5
def.com | "blah2" | 10

I want to eliminate rows containing any search term where the sum of
searches across all hosts is more than 200.

So for example, if the sum of searches for the keyword "blah" across
all hosts is 350, then I would want to eliminate all individual rows
containing the keyword "blah".

I'm new to SQL, so would welcome pointers on the fastest way to do this.

Nov 13 '05 #1
2 1300
Off the top of my head, something like the following should do it if
your table was called [foo]:

DELETE * FROM foo
WHERE
search_term IN (
SELECT search_term FROM foo
GROUP BY search_term
HAVING (SUM(number_of_searches)>200)
)

Nov 13 '05 #2
Thanks, I'll give this a try.

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BF | last post by:
Hello, I am trying to find out if there is a way to limit the number of rows returned when a cursor is opened. I am using DB2 version 7 on z/OS. The SELECT statement in my DECLARE CURSOR...
1
by: James | last post by:
Access 2003, trying to count the number of records that meet a criteria. According to Help: "In the Database window, click Queries under Objects, and then click New on the database window...
10
by: neb | last post by:
Dear member of the forum, Ms access has built-in aggregate function like: -Sum, Max, First, Avg, ... Is it possible to build user-defined aggregate? (if you have any clue, do not hesitate to...
3
by: MrNobody | last post by:
I've read that the expression property for DataColumns is used to "Sets or retrieves the expresssion used to filter rows, calculate the values in a column, or create an aggregate column.". I...
0
by: Geoff Jones | last post by:
Hi guys I'd be grateful if you could help me with the following question: I have a DataSet in which I'm using a SQL search string to find rows which satisfy a criteria. I'd then like to...
5
by: Dean | last post by:
Has anyone toiled with creating/using alternate domain aggregate functions? I have been messing with that a little. The one recordsource I have been working indicates I get 20 to 40% savings in...
1
by: Bhujanga | last post by:
I have some reports whose purpose is to show whether any records currently meet certain criteria, so of course the report is based on a query where that criteria is defined. If there don't happen to...
5
by: Soccer5 | last post by:
Trying to Count records on a report that meet a certain criteria. Have a text box in the Report Footer that has the following in the Control Source: =Count(="S") This does not work. It...
15
by: Andy B | last post by:
I need to count files in a certain directory that has the string -Contract Template.xml at the end of it. How would I do this?
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.