Forum Discussion
Anonymous
4 years agoNot applicable
DECLARE statement in PBI using DirectQuery
Hi, I'm using a direct query SQL in PBI. While using a DECLARE statement, it throws an error Incorrect syntax near the keyqord 'DECLARE'. Incorrect syntax near ')' My SQL statement is as fol...
mimimon
1 year agoNew Member
Hey if anyone still looking for solution try to change your query , use cte instead of declare .
using declare :
DECLARE @effect_date as date;
Set @effect_date= (select distinct effective_date from in.input_table)
select * from abc
join ....
group by....
using cte:
WITH date AS (
SELECT
distinct effective_date from in.input_table AS effect_date)
SELECT * FROM date
hope it helps