Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreThe FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now
I am pulling query from Oracle Database into Power BI that outputs this
but I want it to output this
I thought MIN(I.CREATIONDATE) would give date-time with earliest hour in my original query
SELECT TO_CHAR(MIN(I.INCIDENTID)) AS "Incident ID",
MIN(I.CREATIONDATE) AS "Creation Date",
TO_CHAR(I.CREATIONDATE,'MM-DD-YYYY') AS "Date",
TRIM(MO.DOMAINUSERNAME) AS "Login ID",
TRIM(M.MESSAGESUBJECT) AS "Email Subject"
FROM MESSAGE M
JOIN INCIDENT I
ON M.MESSAGESOURCE = I.MESSAGESOURCE
AND M.MESSAGEID = I.MESSAGEID
AND M.MESSAGEDATE = I.MESSAGEDATE
JOIN MESSAGEORIGINATOR MO
ON M.MESSAGEORIGINATORID = MO.MESSAGEORIGINATORID
GROUP BY TO_CHAR(I.CREATIONDATE,'MM-DD-YYYY'),
TRIM(MO.DOMAINUSERNAME),
TRIM(M.MESSAGESUBJECT)
Then I was advised to use CTE with row_number() but now I get
Message=ORA-00933: SQL command not properly ended
I tried many variations. How to fix this?
with CTE as (
SELECT MyTable.*,
row_number() over (PARTITION BY MIN(I.CREATIONDATE) ORDER BY I.CREATIONDATE) AS rn
FROM MyTable
)
SELECT *
FROM CTE
WHERE rn = 1
SELECT TO_CHAR(MIN(I.INCIDENTID)) AS "Incident ID",
MIN(I.CREATIONDATE) AS "Creation Date",
TO_CHAR(I.CREATIONDATE,'MM-DD-YYYY') AS "Date",
TRIM(MO.DOMAINUSERNAME) AS "Login ID",
TRIM(M.MESSAGESUBJECT) AS "Email Subject"
FROM MESSAGE M
JOIN INCIDENT I
ON M.MESSAGESOURCE = I.MESSAGESOURCE
AND M.MESSAGEID = I.MESSAGEID
AND M.MESSAGEDATE = I.MESSAGEDATE
JOIN MESSAGEORIGINATOR MO
ON M.MESSAGEORIGINATORID = MO.MESSAGEORIGINATORID
GROUP BY TO_CHAR(I.CREATIONDATE,'MM-DD-YYYY'),
TRIM(MO.DOMAINUSERNAME),
TRIM(M.MESSAGESUBJECT)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |