我正在使用以下基于loadspeed.js示例的代码打开一个https://站点,该站点也需要http服务器身份验证.
var page = require('webpage').create(), system = require('system'), t, address;
page.settings.userName = 'myusername';
page.settings.password = 'mypassword';
if (system.args.length === 1) {
console.log('Usage: scrape.js <some URL>');
phantom.exit();
} else {
t = Date.now();
address = system.args[1];
page.open(address, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
} else {
t = Date.now() - t;
console.log('Page title is ' + page.evaluate(function () {
return document.title;
}));
console.log('Loading time ' + t + ' msec');
}
phantom.exit();
});
} …
Run Code Online (Sandbox Code Playgroud) 如何WHERE
在OVER
子句中使用子句进行过滤?
即来自以下数据
LoanID | Principal | Tenor | AmortizingPrincipal
----------------------------------------
1 20000 1 5000
1 20000 2 5000
1 20000 3 5000
1 20000 4 5000
Run Code Online (Sandbox Code Playgroud)
我需要在每个Tenor中使用Balance Principal的第四个虚拟列,如下所示:
LoanID | Principal | Tenor | AmortizingPrincipal | BalancePrinicpal
-----------------------------------------------------------
1 20000 1 5000 20000
1 20000 2 5000 15000
1 20000 3 5000 10000
1 20000 4 5000 5000
Run Code Online (Sandbox Code Playgroud)
像这样的东西:
SELECT
BalancePrincipal = Principal - SUM(AmortizingPrincipal) OVER(PARTITION BY LoanID WHERE Tenor < this row's tenor)
Run Code Online (Sandbox Code Playgroud)
更新:
以下查询为我提供了所需的结果: …