Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 21st, 2012, 01:48 PM
daloser daloser is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Posts: 1 daloser User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 3 sec
Reputation Power: 0
Having a problem with HAVING

The "HAVING" statement from the query below removes all rows where the "name" field starts with "Port" and it removes all rows where count is less than 11. What I want is to removes all rows where the "name" field starts with "Port" and the count for that row is less than 11.

Any help or suggestions will be much appreciated.

Thanks -

SELECT deviceEventClassId "Event ID", deviceAddress "Device Address", name "Event Name", deviceHostName "Device Host Name", count( concat(deviceEventClassId, deviceHostName, name)) "Count"
FROM events
WHERE (deviceVendor = "Bilbo" and
name not like '%config%)
group by deviceHostName, deviceEventClassId, name
HAVING (name not like ('Port%') and
count(concat(deviceEventClassId, deviceHostName, name)) > 11)
order by deviceHostName

Reply With Quote
  #2  
Old June 24th, 2012, 12:54 AM
spacebar208's Avatar
spacebar208 spacebar208 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2012
Location: spaceBAR Central
Posts: 191 spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level)spacebar208 User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 9 h 59 m 25 sec
Reputation Power: 41
Try these two statements and see if this is what you are looking for:
Code:
with dcnt as(
  select deviceeventclassid, devicehostname, name, count(*) as dev_count
   from  events
  where  devicevendor  =  'Bilbo'
   and   name not like '%config%'
  group by deviceeventclassid, devicehostname, name )
select d.deviceeventclassid as "Event ID", e.deviceaddress as "Device Address", d.name as "Event Name",
       d.devicehostname as "Device Host Name", d.dev_count as "Count"
 from  dcnt d join events e on d.deviceeventclassid  =  e.deviceeventclassid
                           and d.devicehostname      =  e.devicehostname
                           and d.name                =  e.name
where  d.name not like 'Port%'
  or   ( d.name like 'Port%'
 and     d.dev_count  <  11 )
order by d.devicehostname

select deviceEventClassId "Event ID", deviceAddress "Device Address", name "Event Name", deviceHostName "Device Host Name",
       count( concat(deviceEventClassId, deviceHostName, name)) "Count"
 from  events
where  deviceVendor  =  'Bilbo'
 and   name not like '%config%'
group by deviceHostName, deviceEventClassId, name
having name not like 'Port%'
  or   ( name like 'Port%'
 and     count( concat( deviceEventClassId, deviceHostName, name ) ) > 11 )
order by deviceHostName

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Having a problem with HAVING

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap