LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-19-2008, 08:15 PM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
sql - select, count, join, group


How can I get this to work, this is being done on an Oracle database. Needs a group by caluse, but not sure where to put it..

select distinct(LEASE.MAC), count(*)
FROM REPORTING.LEASE
JOIN REPORTING.EQUIPMENT
ON LEASE.MAC = EQUIPMENT.MAC
WHERE count(*)>2
AND EQUIPMENT.DEVICETYPE='cm'
GROUP BY count(*);
 
Old 11-19-2008, 10:07 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
What exactly do you want to group by? The mac addresses or the number of duplicate entries in the lease table?

if you want to group by mac and get a count of each in the grouping, it would be something like this:

Code:
select t1.mac, count(t1.mac) from lease t1, equipment t2
where t1.mac = t2.mac and t2.devicetype = 'cm'
group by (t1.mac);
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL SELECT Group by 2 conditions MicahCarrick Programming 1 01-30-2007 10:02 PM
MySQL Select Count Question robgo777 Programming 9 01-07-2005 05:54 AM
Sql + Oracle Select If ???? smaida Programming 11 12-15-2004 08:13 PM
SELECT and INNER JOIN Gerardoj Programming 1 06-07-2004 03:09 PM
Bizarre SQL select query acid_kewpie Programming 6 01-20-2004 12:47 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration