I have set up a data extension to capture a query and return it's results. In order to track the query, I am running it in automation studio. However, the query keeps failing. I have checked that the fields are consistent with those of the query, but still it fails.
Here is a copy of the query:
SELECT
SubscriberKey
, EmailAddress
, FirstName
, Username
, B.bet_market_name
, B.bet_market_selection
FROM [Email Audience - Marketing] E
JOIN (
SELECT customer_id
, bet_market_name
, bet_market_selection
FROM (
SELECT customer_id
, bet_market_name
, bet_market_selection
, ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY BT.bet_id ASC) AS rowNum
FROM BetTransaction BT
JOIN (
SELECT
bet_market_selection
, bet_id
, bet_market_name
FROM BetSelection BS
WHERE amount >= 5
AND win_price >= 1.5
AND bet_category_name = 'Football (Premier League)'
) BS
ON BT.bet_id = BS.bet_id
WHERE multi = 1
) as B
WHERE rowNum = 1
) as B
ON E.customer_id = B.customer_id
B
alias?