以下查询会产生所需的结果。
SELECT client.client_code,client.client_name,dealing_record.transaction_number,
transaction_type.transaction,payment_status.status,payment_record.Amount_settled,
payment_record.payment_date
FROM client inner Join payment_record on payment_record.client_id= client.client_id
inner join dealing_record on
dealing_record.dealing_record_id=payment_record.dealing_id
inner join payment_status on
payment_record.payment_status_id=payment_status.payment_status_id
inner Join transaction_type on
dealing_record.transaction_type_id=transaction_type.transaction_type_id
WHERE status='pending settlement' AND payment_date BETWEEN '07-Nov-2010' AND
'17-Nov-2013';
还有另一种方法可以用较小的内部连接来完成吗?
答案 0 :(得分:0)
优化的最佳方法是查看执行计划。
执行计划将告知查询何时使用索引,并且通过该信息,您可以采取措施更改索引结构。
查看此问题中的信息
Optimizing Execution Plans for Parameterized T-SQL Queries Containing Window Functions