我想用示例数据制作一张表,但是我的对象可以有多个主题,并且主题内可以有多个帖子。
[
{
"topicName":"First topic",
"postInformations":[
{
"postName":"First post",
"postNumbers":{
"number1":111,
"number2":222,
"number3":333
}
}
],
"topicNumbers":{
"number1":123,
"number2":456,
"number3":789
}
}
]
那就是我想要达到的目标:
|[topicName | postName ]|[number1]|[number2]|[number3]|
| First topic | 111 | 222 | 333 |
| First post | 444 | 555 | 666 |
通常我会在HTML中通过一栏设置一列来轻松地做到这一点,但是我不知道主题有多少个帖子,主题有多少个。
有什么主意如何使其与未知的帖子和主题兼容?
答案 0 :(得分:1)
您可以使用嵌套的ngFor。这样的事情。
select dc_id, Mosah_code, **field_x, field_y**, [31] , [32] ,[33], [34]
from (select dc.dc_id, dc.Mosah_code, **field_x, field_y**, dp.Sapak_code, dp.DC_Pprice_after_discount from DcnezekCloudAuction dc
left join DcnezekCloudAuctionParts dp on dc.dc_id = dp.DC_ID and dp.Mosah_code = dc.Mosah_code) as S
pivot
(
sum (DC_Pprice_after_discount)
FOR Sapak_Code IN ([31], [32], [33], [34])
)AS P