LynneSin
(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?
|
ikri
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 10:56 AM
Response to Original message |
|
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.
|
LynneSin
(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!!!
|
aePrime
(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
|
no name no slogan
(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.
|
kick-ass-bob
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 11:14 AM
Response to Reply #4 |
|
you forgot 'on the mainframe'
:D
|
no name no slogan
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 11:17 AM
Response to Reply #5 |
|
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!
|
kick-ass-bob
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 11:20 AM
Response to Reply #6 |
LynneSin
(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:
|
no name no slogan
(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...
|
LynneSin
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 12:49 PM
Response to Reply #9 |
10. Now you're just dating yourself |
no name no slogan
(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:
|
billyskank
(1000+ posts)
Send PM |
Profile |
Ignore
|
Tue Sep-20-05 12:50 PM
Response to Original message |
|
but you need something like
SELECT foo,bar, COUNT(*) FROM baz,qux WHERE quux GROUP BY yada,yada,yada HAVING COUNT (*) >= 20.
|
DU
AdBot (1000+ posts) |
Thu Apr 25th 2024, 09:43 AM
Response to Original message |