Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
The connection when connecting straight to the database works perfectly. However, when I add a SQL statement in the connection, it does not work. It has worked previously when using a SQL statement, so there must be something wrong with the current one I am trying to use? I cannot seem to figure it out though. Please help!! 🙂
Here is the statement:
SELECT
trim(P.policyNumber) AS 'Policy number',
PH.title AS 'Policy stage',
PH._policyHistoryInterfaceTypeEnum AS 'Policy stage type',
PH.created_at AS 'Policy stage created at',
PH.updated_at AS 'Policy stage updated at',
PH.deleted_at AS 'Policy stage deleted at',
P.statusEnum AS 'Policy status',
P._policyTypeEnum AS 'Policy type',
P.premium AS 'Policy premium',
P.excess AS 'Policy excess',
P.proRataAmount AS 'Policy prorata',
P.saleDate AS 'Policy sale date',
P.inceptionDate AS 'Policy inception date',
P.debitOrderDate AS 'Policy debit order date',
P.firstDebitDate AS 'Policy first debit date',
P.proRataDate AS 'Policy prorata date',
P.cancellationDate AS 'Policy cancellation date',
CONCAT(U.firstName, ' ', U.lastName) AS 'Client name',
U.dateOfBirth AS 'Client date of birth',
U.genderTypeEnum AS 'Client gender',
U.created_at AS 'Client created at',
U.updated_at AS 'Client updated at',
U.deleted_at AS 'Client deleted at',
(SELECT emailAddress FROM user_leads WHERE LH._leadId = user_leads._id) AS 'Client email',
(SELECT phoneNumber FROM user_leads WHERE LH._leadId = user_leads._id) AS 'Client phone number',
(SELECT heatDate FROM user_leads WHERE LH._leadId = user_leads._id) AS 'Client heat date',
(SELECT sourceTypeEnum FROM user_leads WHERE LH._leadId = user_leads._id) AS 'Client source',
CONCAT(UA.firstName, ' ', UA.lastName) AS 'Admin name',
(SELECT name FROM providers WHERE P._providerId = providers._id) AS 'Provider name',
(SELECT statusEnum FROM providers WHERE P._providerId = providers._id) AS 'Provider status',
PU.policyNumber AS 'Policy number 2',
PU.statusEnum AS 'Policy status 2',
PU.premium AS 'Policy premium 2',
PU.inceptionDate AS 'Policy inception date 2',
PU.debitOrderDate AS 'Policy debit order date 2',
PU.fullName AS 'Client name 2',
PU.phoneNumber AS 'Client phone number 2',
PU.emailAddress AS 'Client email 2'
FROM
policy_histories AS PH
LEFT JOIN policies AS P ON
PH._policyId = P._id
LEFT JOIN user_clients AS UC ON
PH._clientId = UC._id
LEFT JOIN users AS U ON
PH._clientId = U._userId
LEFT JOIN user_admins AS UA ON
PH._adminId= UA._id
LEFT JOIN lead_histories AS LH ON
PH._policyId = LH._policyId
LEFT JOIN policy_uploads AS PU ON
PH._policyId = PU._policyId
@Anonymous ,
Have you solved your issue by now? If you have, could you please help mark the correct answer to finish the thread? Your contribution will be much appreciated.
Regards,
Jimmy Tao
@Anonymous ,
What is the error message? In addtion, you can simplify your sql statement using statement like "select from where". You can do "join" operations in query editor.
Community Support Team _ Jimmy Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 40 | |
| 38 | |
| 33 | |
| 29 | |
| 26 |
| User | Count |
|---|---|
| 131 | |
| 105 | |
| 60 | |
| 56 | |
| 55 |