最初の select ステートメントから返された値に基づいて、一連の select ステートメントを実行したいと考えています。基本的に元の値をループし、その値を新しい選択の基準として使用します。
私がやろうとしていることのいくつかの擬似コード(シェルでこれを書く方法...):
for location in `select places from tablename where XYZ`
do
select new_field from tablename where location = '$location';
done
これが私が本当に実行したい選択です。
ラックのリストを入手してください:
select regexp_substr("MYTABLE"."Serial_Number" ,'[^ ]+', 1, 3) as "Racks"
from "MYTABLE" "MYTABLE"
where "MYTABLE"."Data_Center" ='SOMEPLACE'
and "MYTABLE"."Device_Type" ='RACK'
and "MYTABLE"."Serial_Number" not like '%WAREHOUSE%'
デバイスの数に基づいてラックを所有する必要があるユーザーを出力します。
select count(*) as count, LOB
from "MYTABLE" "MYTABLE"
where "MYTABLE"."Data_Center" ='SOMEPLACE'
and GRID_LOCATION = '$RACK_from_above' and rownum <= 1 group by LOB order by count desc;
前もって感謝します!