答案 0 :(得分:3)
使用支持 SQL 2012 + 的LAG功能,如下所示,我在表格中使用ID作为主键
async function test() {
const data= [];
for (let i = 0; i <= 5; i = i + 1) {
const payload: any = await postExampleApi(i);
data.push(payload);
}
return data;
}
export const getData = test().then((data) => {
console.log(data);
return data;
});
<强>输出:强>
答案 1 :(得分:0)
您通常会在表示层中处理此问题,但您可以尝试以下查询:
SELECT
Date,
CASE WHEN ROW_NUMBER() OVER (PARTITION BY User ORDER BY Date) = 1
THEN User ELSE '' END AS User,
CASE WHEN ROW_NUMBER() OVER (PARTITION BY User ORDER BY Date) = 1
THEN [Source IP] ELSE '' END AS [Source IP],
CASE WHEN ROW_NUMBER() OVER (PARTITION BY User ORDER BY Date) = 1
THEN Destination ELSE '' END AS Destination,
CASE WHEN ROW_NUMBER() OVER (PARTITION BY User ORDER BY Date) = 1
THEN Port ELSE '' END AS Port,
CASE WHEN ROW_NUMBER() OVER (PARTITION BY User ORDER BY Date) = 1
THEN Duration ELSE '' END AS Duration
FROM yourTable;
注意:从您的示例输出中不清楚您是否期望所有记录都Source IP
。如果没有,那么只需修改我的查询。
如果您的SQL Server版本不支持LAG
,那么这可能是一个可行的选择。
答案 2 :(得分:0)
ID NAME DTE
1 RAJIV 2018-02-06 11:04:13.257
2 2018-02-06 11:04:13.257
3 RAVI 2018-02-06 11:04:13.257
4 2018-02-06 11:04:13.257
5 AJAY 2018-02-06 11:04:13.257
选择声明:
localization = navigator.language;
setInterval(() => {
if(this.localization !== navigator.language) {
// call your get method
}
},1000);
输出:
{{1}}