Sponsored Content
Top Forums Programming Sql ORA-00937: not a single-group group function Post 302935142 by cero on Friday 13th of February 2015 03:27:59 AM
Old 02-13-2015
What does didn't work mean? You get wrong results or a syntax error? It works for me:
Code:
select * from
  (select decode(c.extent_management,'LOCAL','*',' ') || b.tablespace_name name,
         max(trunc((decode( kbytes_max, 0, 0, (kbytes_alloc/kbytes_max)*100)))) pct_max_used
    from (select sum(bytes)/1024 Kbytes_free,
                 max(bytes)/1024 largest,
                 tablespace_name
            from sys.dba_free_space
           group by tablespace_name, bytes) a,
         (select sum(bytes)/1024 Kbytes_alloc,
                 sum(maxbytes)/1024 Kbytes_max,
                 tablespace_name
            from sys.dba_data_files
           group by tablespace_name
          union all
          select sum(bytes)/1024 Kbytes_alloc,
                 sum(maxbytes)/1024 Kbytes_max,
                 tablespace_name
            from sys.dba_temp_files
           group by tablespace_name )b,
         dba_tablespaces c
   where a.tablespace_name (+) = b.tablespace_name
     and c.tablespace_name (+) = b.tablespace_name
   group by decode(c.extent_management,'LOCAL','*',' ') || b.tablespace_name
   order by pct_max_used desc)
 where rownum = 1

You have to use another layer of subquery because order by is applied last to the result set.
This User Gave Thanks to cero For This Post:
 

9 More Discussions You Might Find Interesting

1. Solaris

entry in /etc/group too long - problem using sudo with %group

hi folks, I've been googling for quite some time, but still can't find anything near it...my problem is the following: for useradministration in our company we are using ssh/sudo, now whenever I try to add users (we have quite a number of users) with useradd -G groupname for secondary group I... (4 Replies)
Discussion started by: poli
4 Replies

2. Shell Programming and Scripting

Substitute to GROUP BY function

Hi All, I really need a help on this thing. Most of us are aware about the group by function in Oracle. Do we have a substitute ( not necessarily a single line command) to it in Unix? Let me put it this way. I have a file whose content is like file1-: ID1,ID2,ID3,ID4,ID5 1,2,3,123,5... (3 Replies)
Discussion started by: rinku11
3 Replies

3. UNIX for Dummies Questions & Answers

How many user can be added to single group

Hi There, How many user can be added to a unix single group. I need this for unix and solaris. BRs -----Post Update----- I'm asking about secondary group and not primary group. All the users are having 8 character as their username. value is set for getconf LINE_MAX is... (1 Reply)
Discussion started by: maestromani
1 Replies

4. UNIX for Advanced & Expert Users

is it possible to have a 1000 user in single group

I m usi ng RHEL 4 and /etc/group file contains line 7000 characters. so it is possible to have a 1000 user in single group (5 Replies)
Discussion started by: amitpansuria
5 Replies

5. Shell Programming and Scripting

Merge group numbers and add a column containing group names

I have a file in the following format. Groups of data merge together and the group number is indicated above each group. 1 adrf dfgr dfg 2 dfgr dfgr 3 dfef dfr fd 4 fgrt fgr fgg 5 fgrt fgr (3 Replies)
Discussion started by: Lucky Ali
3 Replies

6. Shell Programming and Scripting

Merge group numbers and add a column containing group names

Hi All I do have a file like this with 6 columns. Groups of data merge together and the group number is indicated above each group. 1 1 12 26 289 3.2e-027 GCGTATGGCGGC 2 12 26 215 6.7e+006 TTCCACCTTTTG 3 9 26 175 ... (1 Reply)
Discussion started by: Lucky Ali
1 Replies

7. Shell Programming and Scripting

Sort the file contents in each group....print the group title as well

I've this file and need to sort the data in each group File would look like this ... cat file1.txt Reason : ABC 12345-0023 32123-5400 32442-5333 Reason : DEF 42523-3453 23345-3311 Reason : HIJ 454553-0001 I would like to sort each group on the last 4 fileds and print them... (11 Replies)
Discussion started by: prash184u
11 Replies

8. AIX

Adding a Volume Group to an HACMP Resource Group?

Hi, I have a 2 node Cluster. Which is working in active/passive mode (i.e Node#1 is running and when it goes down the Node#2 takes over) Now there's this requirement that we need a mount point say /test that should be available in active node #1 and when node #1 goes down and node#2 takes... (6 Replies)
Discussion started by: aixromeo
6 Replies

9. Shell Programming and Scripting

need a one liner to grep a group info from /etc/group and use that result to search passwd file

/etc/group tiadm::345:mk789,po312,jo343,ju454,ko453,yx879,iy345,hn453 bin::2:root,daemon sys::3:root,bin,adm adm::4:root,daemon uucp::5:root /etc/passwd mk789:x:234:1::/export/home/dummy:/bin/sh po312:x:234:1::/export/home/dummy:/bin/sh ju454:x:234:1::/export/home/dummy:/bin/sh... (6 Replies)
Discussion started by: chidori
6 Replies
CREATE 
DATABASE(7) PostgreSQL 9.2.7 Documentation CREATE DATABASE(7) NAME
CREATE_DATABASE - create a new database SYNOPSIS
CREATE DATABASE name [ [ WITH ] [ OWNER [=] user_name ] [ TEMPLATE [=] template ] [ ENCODING [=] encoding ] [ LC_COLLATE [=] lc_collate ] [ LC_CTYPE [=] lc_ctype ] [ TABLESPACE [=] tablespace_name ] [ CONNECTION LIMIT [=] connlimit ] ] DESCRIPTION
CREATE DATABASE creates a new PostgreSQL database. To create a database, you must be a superuser or have the special CREATEDB privilege. See CREATE USER (CREATE_USER(7)). By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE name. In particular, by writing TEMPLATE template0, you can create a virgin database containing only the standard objects predefined by your version of PostgreSQL. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1. PARAMETERS
name The name of a database to create. user_name The role name of the user who will own the new database, or DEFAULT to use the default (namely, the user executing the command). To create a database owned by another role, you must be a direct or indirect member of that role, or be a superuser. template The name of the template from which to create the new database, or DEFAULT to use the default template (template1). encoding Character set encoding to use in the new database. Specify a string constant (e.g., 'SQL_ASCII'), or an integer encoding number, or DEFAULT to use the default encoding (namely, the encoding of the template database). The character sets supported by the PostgreSQL server are described in Section 22.3.1, "Supported Character Sets", in the documentation. See below for additional restrictions. lc_collate Collation order (LC_COLLATE) to use in the new database. This affects the sort order applied to strings, e.g. in queries with ORDER BY, as well as the order used in indexes on text columns. The default is to use the collation order of the template database. See below for additional restrictions. lc_ctype Character classification (LC_CTYPE) to use in the new database. This affects the categorization of characters, e.g. lower, upper and digit. The default is to use the character classification of the template database. See below for additional restrictions. tablespace_name The name of the tablespace that will be associated with the new database, or DEFAULT to use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database. See CREATE TABLESPACE (CREATE_TABLESPACE(7)) for more information. connlimit How many concurrent connections can be made to this database. -1 (the default) means no limit. Optional parameters can be written in any order, not only the order illustrated above. NOTES
CREATE DATABASE cannot be executed inside a transaction block. Errors along the line of "could not initialize database directory" are most likely related to insufficient permissions on the data directory, a full disk, or other file system problems. Use DROP DATABASE (DROP_DATABASE(7)) to remove a database. The program createdb(1) is a wrapper program around this command, provided for convenience. Although it is possible to copy a database other than template1 by specifying its name as the template, this is not (yet) intended as a general-purpose "COPY DATABASE" facility. The principal limitation is that no other sessions can be connected to the template database while it is being copied. CREATE DATABASE will fail if any other connection exists when it starts; otherwise, new connections to the template database are locked out until CREATE DATABASE completes. See Section 21.3, "Template Databases", in the documentation for more information. The character set encoding specified for the new database must be compatible with the chosen locale settings (LC_COLLATE and LC_CTYPE). If the locale is C (or equivalently POSIX), then all encodings are allowed, but for other locale settings there is only one encoding that will work properly. (On Windows, however, UTF-8 encoding can be used with any locale.) CREATE DATABASE will allow superusers to specify SQL_ASCII encoding regardless of the locale settings, but this choice is deprecated and may result in misbehavior of character-string functions if data that is not encoding-compatible with the locale is stored in the database. The encoding and locale settings must match those of the template database, except when template0 is used as template. This is because other databases might contain data that does not match the specified encoding, or might contain indexes whose sort ordering is affected by LC_COLLATE and LC_CTYPE. Copying such data would result in a database that is corrupt according to the new settings. template0, however, is known to not contain any data or indexes that would be affected. The CONNECTION LIMIT option is only enforced approximately; if two new sessions start at about the same time when just one connection "slot" remains for the database, it is possible that both will fail. Also, the limit is not enforced against superusers. EXAMPLES
To create a new database: CREATE DATABASE lusiadas; To create a database sales owned by user salesapp with a default tablespace of salesspace: CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace; To create a database music which supports the ISO-8859-1 character set: CREATE DATABASE music ENCODING 'LATIN1' TEMPLATE template0; In this example, the TEMPLATE template0 clause would only be required if template1's encoding is not ISO-8859-1. Note that changing encoding might require selecting new LC_COLLATE and LC_CTYPE settings as well. COMPATIBILITY
There is no CREATE DATABASE statement in the SQL standard. Databases are equivalent to catalogs, whose creation is implementation-defined. SEE ALSO
ALTER DATABASE (ALTER_DATABASE(7)), DROP DATABASE (DROP_DATABASE(7)) PostgreSQL 9.2.7 2014-02-17 CREATE DATABASE(7)
All times are GMT -4. The time now is 11:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy