Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

SQL experts help again please

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
This topic is archived.
Home » Discuss » The DU Lounge Donate to DU
 
LynneSin Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 10:50 AM
Original message
SQL experts help again please
I'm pulling a list of about 10k files but I want to narrow my search to only those files that show up 20 or more times on the list.

Didn't have counting in my class any help?

Any recommendations?
Printer Friendly | Permalink |  | Top
ikri Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 10:56 AM
Response to Original message
1. You need to group
If, for example, you wanted a list of company names that appear more than 20 times in a table you'd use:

Select d.CompanyName, count(*) as 'Total'
from exampletable as d
group by d.CompanyName
having count(*) > 20
order by count(*) desc

That should work.
Printer Friendly | Permalink |  | Top
 
LynneSin Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:12 AM
Response to Reply #1
3. the group command, damnit
forgot about that.

It'll have to wait until after lunch

Thanks!!!
Printer Friendly | Permalink |  | Top
 
aePrime Donating Member (676 posts) Send PM | Profile | Ignore Tue Sep-20-05 10:58 AM
Response to Original message
2. You can try something similar to:
SELECT files, COUNT(*) AS count FROM table GROUP BY file HAVING count >= 20
Printer Friendly | Permalink |  | Top
 
no name no slogan Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:14 AM
Response to Original message
4. databases are for wussies
If you can't store it in a plain-text flat file, it ain't worth storing.
Printer Friendly | Permalink |  | Top
 
kick-ass-bob Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:14 AM
Response to Reply #4
5. on the mainframe!
you forgot 'on the mainframe'

:D
Printer Friendly | Permalink |  | Top
 
no name no slogan Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:17 AM
Response to Reply #5
6. d'oh!
and from the command prompt too, dammit!

I like to run this little baby on the Solaris b0xen at work-- but only when I'm logged in as root:

rm -r /

You should see the look on the tech guys faces when they try to log into the machines. It's priceless!
Printer Friendly | Permalink |  | Top
 
kick-ass-bob Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:20 AM
Response to Reply #6
7. LOL!!
I love that game!

:rofl:
Printer Friendly | Permalink |  | Top
 
LynneSin Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:20 AM
Response to Reply #4
8. I work with a plain-text flat file
Built a database program around it

SO THERE!!!

I'm not a wussy

:woohoo:
Printer Friendly | Permalink |  | Top
 
no name no slogan Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 11:41 AM
Response to Reply #8
9. Betcha can't do that with punchcards, though
monitors are for the weak. Give me a cardreader and a keypunch ANY day.

My hand-punched Assembler routine can whip your pansy-assed SQL query's butt. Especially once I get my System 360 warmed up.

Kids these days...
Printer Friendly | Permalink |  | Top
 
LynneSin Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 12:49 PM
Response to Reply #9
10. Now you're just dating yourself
:P
Printer Friendly | Permalink |  | Top
 
no name no slogan Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 01:05 PM
Response to Reply #10
12. No, I actually have a girlfriend now
My days of self-dating are in the past, thankyouverymuch :silly:
Printer Friendly | Permalink |  | Top
 
billyskank Donating Member (1000+ posts) Send PM | Profile | Ignore Tue Sep-20-05 12:50 PM
Response to Original message
11. Not much info there
but you need something like

SELECT foo,bar, COUNT(*)
FROM baz,qux
WHERE quux
GROUP BY yada,yada,yada
HAVING COUNT (*) >= 20.
Printer Friendly | Permalink |  | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Thu Apr 25th 2024, 09:43 AM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » The DU Lounge Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC