私の現在の役割では、SQLに新たに何が追加されているのですか?クエリでこれを行うには(例)?
次のクエリを実行するにはどうすればよいですか?
select *
from property.lease_period lp
where lp.lease_current_stop_date < getdate() and (lp.lease_status = 'Active' or lp.lease_status = 'Overholding')
and lp.period_id = 263 --- Period ID
and lp.building_id = 40000 --- Building ID
and not (SELECT *
FROM property.lease_period lp
inner join lease_deal.lease ld on lp.suite_id = ld.tenancy_reference
where lp.lease_current_stop_date < getdate() and (lp.lease_status = 'Active' or lp.lease_status = 'Overholding')
and lp.period_id = 263
and lp.building_id = 40000)
は基本的に私はからの結果を表示する:基本的な質問のための
SELECT *
FROM property.lease_period lp
inner join lease_deal.lease ld on lp.suite_id = ld.tenancy_reference
where lp.lease_current_stop_date < getdate() and (lp.lease_status = 'Active' or lp.lease_status = 'Overholding')
and lp.period_id = 263
and lp.building_id = 40000
申し訳ありません:
select *
from property.lease_period lp
where lp.lease_current_stop_date < getdate() and (lp.lease_status = 'Active' or lp.lease_status = 'Overholding')
and lp.period_id = 263 --- Period ID
and lp.building_id = 40000 --- Building ID
一致する結果を含めずに!また、私のSQLをより良くフォーマットするためのこれ以外のヒントもあれば幸いです!
編集:
私はこれは私が探しているものに溶液であってもよいと考えている:
select
*
from
property.lease_period lp
where
lp.lease_current_stop_date < getdate() and (lp.lease_status = 'Active' or lp.lease_status = 'Overholding')
and lp.period_id = 263 --- Period ID
and lp.building_id = 40000 --- Building ID
and not exists
(
select 1
from lease_deal.lease
where lp.suite_id = tenancy_reference
)
order by period_id desc
これを書くためのより良い方法を聞き間違い興味を持って!
私はあなたが探している文は:例外です。 2つのステートメントの間でそれを叩き、魔法が起こるのを見てください。)...私はあなたが何とか1つのクエリで求める結果を得ることができるかと疑っています。 –