Hi all,

Although Tom's SQL statement works very well, there seems to be something weird 
in the way the WHERE statement is handled. This is the output on a server with 
a directory container pool:

select * from (select cast(sum(used_db_space_mb/tot_file_system_mb*100) as 
decimal(3,1)) as "Database" from db) as database, (select pct_utilized as 
"Containerpool" from stgpools where stgpool_name like 'CONTAINER%') as stgpool

 Database      Containerpool
---------     --------------
      6.9               30.3

And now on a server without one:

select * from (select cast(sum(used_db_space_mb/tot_file_system_mb*100) as 
decimal(3,1)) as "Database" from db) as database, (select pct_utilized as 
"Containerpool" from stgpools where stgpool_name like 'CONTAINER%') as stgpool

ANR2034E SELECT: No match found using this criteria.
ANS8001I Return code 11.

So, it looks like the stgpool_name like 'CONTAINER%' statement is also applied 
to the first SQL statement. That's weird, right?

Kind regards,
Eric van Loon
Air France/KLM Storage & Backup


-----Original Message-----
From: ADSM: Dist Stor Manager <ADSM-L@VM.MARIST.EDU> On Behalf Of Tommaso 
Bollini
Sent: donderdag 26 maart 2020 17:34
To: ADSM-L@VM.MARIST.EDU
Subject: R: [ADSM-L] Combining SQL queries

I need to use different syntax from the one of  Eric, like:

select * from (select count(*) as "Number_Of_Failed" from events where 
scheduled_start>current_timestamp-24 hours and status='Failed') as failed, 
(select count(*) as "Number_Of_Missed" from events where 
scheduled_start>current_timestamp-24 hours and status='Missed') as missed

since I've got a 'ANS8001I Return code 28'

Tom.


-----Messaggio originale-----
Da: ADSM: Dist Stor Manager <ADSM-L@VM.MARIST.EDU> Per conto di Skylar Thompson
Inviato: giovedì 26 marzo 2020 17:14
A: ADSM-L@VM.MARIST.EDU
Oggetto: Re: [ADSM-L] Combining SQL queries

Hi Eric,

You can combine these two queries by executing them as subqueries:

select
   *
from (
   select count(*) as "Number_Of_Failed" from events where 
scheduled_start>current_timestamp-24 hours and status='Failed'
) failed,
(
   select count(*) as "Number_Of_Missed" from events where 
scheduled_start>current_timestamp-24 hours and status='Missed'
) missed
;

Hope that helps!

On Thu, Mar 26, 2020 at 03:51:23PM +0000, Loon, Eric van (ITOP NS) - KLM wrote:
> Hi guys,
>
> I have two SQL queries:
>
> select count(*) as "Number_Of_Failed" from events where 
> scheduled_start>current_timestamp-24 hours and status='Failed'
> select count(*) as "Number_Of_Missed" from events where 
> scheduled_start>current_timestamp-24 hours and status='Missed'
>
> Is it somehow possible to combine them into one single query? I know I can 
> use and status='Failed' or status='Missed', but I would like to be able to 
> see how many are missed and how many are failed separately. My aim is to see 
> if I can use one single line (with multiple columns) to report this in SPOC.
> Thanks for any help in advance!
>
> Kind regards,
> Eric van Loon
> Air France/KLM Storage & Backup
> ********************************************************
> For information, services and offers, please visit our web site: 
> http://www.klm.com. This e-mail and any attachment may contain confidential 
> and privileged material intended for the addressee only. If you are not the 
> addressee, you are notified that no part of the e-mail or any attachment may 
> be disclosed, copied or distributed, and that any other action related to 
> this e-mail or attachment is strictly prohibited, and may be unlawful. If you 
> have received this e-mail by error, please notify the sender immediately by 
> return e-mail, and delete this message.
>
> Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its 
> employees shall not be liable for the incorrect or incomplete transmission of 
> this e-mail or any attachments, nor responsible for any delay in receipt.
> Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch 
> Airlines) is registered in Amstelveen, The Netherlands, with registered 
> number 33014286
> ********************************************************

--
-- Skylar Thompson (skyl...@u.washington.edu)
-- Genome Sciences Department, System Administrator
-- Foege Building S046, (206)-685-7354
-- University of Washington School of Medicine
********************************************************
For information, services and offers, please visit our web site: 
http://www.klm.com. This e-mail and any attachment may contain confidential and 
privileged material intended for the addressee only. If you are not the 
addressee, you are notified that no part of the e-mail or any attachment may be 
disclosed, copied or distributed, and that any other action related to this 
e-mail or attachment is strictly prohibited, and may be unlawful. If you have 
received this e-mail by error, please notify the sender immediately by return 
e-mail, and delete this message.

Koninklijke Luchtvaart Maatschappij NV (KLM), its subsidiaries and/or its 
employees shall not be liable for the incorrect or incomplete transmission of 
this e-mail or any attachments, nor responsible for any delay in receipt.
Koninklijke Luchtvaart Maatschappij N.V. (also known as KLM Royal Dutch 
Airlines) is registered in Amstelveen, The Netherlands, with registered number 
33014286
********************************************************

Reply via email to