In case you have your own slow SQL query, you can optimize it automatically here.
For the query above, the following recommendations will be helpful as part of the SQL tuning process.
You'll find 3 sections below:
SELECT
bid,
PurAmount,
row_number() OVER (ORDER
BY
id,
bill_date,
type) AS rrn,
RunningTotal,
rn
FROM
View_6 I1
OUTER APPLY (SELECT
SUM(I2.PurchaseAvg * I2.PurAmount) / NULLIF(SUM(I2.PurAmount),
0) RunningTotal FROM
View_6 I2
WHERE
I1.id = I2.id
AND I1.IslId = I2.IslId
AND I1.rn >= I2.rn
AND I2.TYPE = 1) C