There is a field in the stgpools table that shows how many tapes are used, so I don't think you need a join.
select MAXSCRATCH, NUMSCRATCHUSED from stgpools The way I monitor maxscratch is with this: select STGPOOL_NAME, MAXSCRATCH, NUMSCRATCHUSED from stgpools where MAXSCRATCH is not null and (MAXSCRATCH - NUMSCRATCHUSED)<10 If that command returns succesfully, then the Storage Pool will accept less than 10 new scratch tapes. (the "not null" is to exclude Random pools) Regards, Shawn ________________________________________________ Shawn Drew Internet g...@bsu.edu Sent by: ADSM-L@VM.MARIST.EDU 04/06/2010 03:10 PM Please respond to ADSM-L@VM.MARIST.EDU To ADSM-L cc Subject [ADSM-L] Sql query help Tsm server 5.5.4 running on suse 9 linux under zvm 5.3. Trying to create a query which will give me the count of volumes in a storage pool, and its maxscratch setting on a single line. Nice to watch for filling pools which need a larger maxscratch value. Query follows: --------------- select a.stgpool_name as "Storage Pool Name", - a.devclass as "Device Class Name", - count( b.volume_name) as " # VOLUMES", - a.maxscratch as "volumes available" - from stgpools a, volumes b - where a.devclass <>'DISK' - and a.devclass = b.devclass_name - group by a.stgpool_name, a.devclass --------- query ends. ------------ Thanks for any help. Gary Lee Senior System Programmer Ball State University phone: 765-285-1310 This message and any attachments (the "message") is intended solely for the addressees and is confidential. If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval. The internet can not guarantee the integrity of this message. BNP PARIBAS (and its subsidiaries) shall (will) not therefore be liable for the message if modified. Please note that certain functions and services for BNP Paribas may be performed by BNP Paribas RCC, Inc.