我使用的代码是:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" media-type="text/html" encoding="UTF-8" />
<xsl:variable name="Profile">
<xsl:value-of select="/Profile" />
</xsl:variable>
<xsl:template match="/">
<html>
<head>
<meta charset="utf-8" />
</head>
<script>
sap.ui.getCore().attachInit(function () {
sap.ui.require([
"sap/m/Shell",
"sap/ui/core/ComponentContainer",
"sap/ui/model/xml/XMLModel"
], function
(Shell, ComponentContainer, XMLModel) {
new Shell({
app: new
ComponentContainer({
height : "100%",
name : "App"
}
)}
).placeAt("container");
var dataProfile = "<xsl:value-of select="$Profile" />";
var oModel = new XMLModel();
oModel.setXML(dataProfile);
sap.ui.getCore().setModel(oModel,"Profile");
});
});
</script>
<body class="sapUiBody">
<xsl:element name="div">
<xsl:attribute name="data-sap-ui-component">main</xsl:attribute>
<xsl:attribute name="data-name">app</xsl:attribute>
<xsl:attribute name="data-id">container</xsl:attribute>
<xsl:attribute name="data-settings">'{"id": "app"}'</xsl:attribute>
</xsl:element>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我正在寻找的输出将只有一行,但是,我却得到了两行。有人知道如何将它们合并为一个吗?
答案 0 :(得分:4)
使用条件聚合:
SELECT AccountFK,
MAX(CASE WHEN B.ContractType = 'Telecoms' Then B.TermFeeMethod END) AS TelecomsTermMethod,
MAX(CASE WHEN B.ContractType = 'Broadband' Then B.TermFeeMethod END) AS BroadbandTermMethod,
MAX(CASE WHEN B.ContractType = 'Mobile' Then B.TermFeeMethod END) AS MobileTermMethod,
MAX(CASE WHEN B.ContractType = 'Water' Then B.TermFeeMethod END) AS WaterTermMethod,
ROW_NUMBER () OVER (PARTITION BY B.AccountFK ,B.TermFeeMethod ORDER BY A.CreatedDate DESC) AS RowNo
FROM CRM.Contract.TermFeeTransaction A JOIN
ContractSnapshot B
ON A.ContractFK = B.ContractID
WHERE CAST(b.CreatedDate as date) between '20180101' and '20190812' AND
B.TermFeeMethod IS NOT NULL AND
ContractType IN ('Telecoms', 'Broadband', 'Mobile', 'Water') AND
AccountFK = '12345'
GROUP BY AccountFK;
注意:A
和B
对于表别名来说确实是错误的选择。它们只是任意字母。您应该改用tft
和cs
-这些是表名的缩写。