RE: Quick SQL assistance
Date: Mon, 14 Sep 2009 15:33:51 -0500
Interesting....I think this will work, but had to add a TRIM to the TO_CHAR as it has spaces around "SUNDAY" (in my case).
select host_name, target_name, to_char(snap_date,'DAY'), snap_date, tablespace_size_mb
select distinct HOST_NAME,
TARGET_NAME, TARGET_DESC, TARGET_TYPE,
round(SUM(TABLESPACE_SIZE/1024/1024),2) as TABLESPACE_SIZE_MB, round(sum(TABLESPACE_FREE_SIZE/1024/1024),2) as TABLESPACE_FREE_SIZE_MB, round(sum(TABLESPACE_USED_SIZE/1024/1024),2) as TABLESPACE_USED_SIZE_MB, round((sum(tablespace_used_size)/sum(tablespace_size))*100,2) as TABLESPACE_PERCENT_USEDfrom db_tablespaces
group by host_name, target_name, target_desc, target_type, snap_date order by host_name, target_name
where to_char(snap_date,'D')=1 (Thanks to Christopher Boyle for that one as well)
I've never used TO_CHAR that way before. Very enlightening!!
Sr. Oracle DBA
Ingram Barge Company
Nashville, TN 37205
CONFIDENTIALITY NOTICE: This e-mail and any attachments are confidential and may also be privileged. If you are not the named recipient, please notify the sender immediately and delete the contents of this message without disclosing the contents to anyone, using them for any purpose, or storing or copying the information on any medium.
From: Allen, Brandon [mailto:Brandon.Allen_at_OneNeck.com] Sent: Monday, September 14, 2009 3:25 PM To: Taylor, Chris David; 'Oracle L'
Subject: RE: Quick SQL assistance
I'm not sure if I understand what you're trying to get - you mean you only want it to return records where snap_date is a Tuesday? If so, you can do that with this syntax:
WHERE to_char(snap_date,'DAY') = 'TUESDAY'
Privileged/Confidential Information may be contained in this message or attachments hereto. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of this company shall be understood as neither given nor endorsed by it. Received on Mon Sep 14 2009 - 15:33:51 CDT