I have a CTE as part of my overall SQL statement. I'm building a field and want to call it Hours, and I use that in the main Select statement. The CTE combines several store hours records for each store into one record. My statement runs fine outside Valence and produces accurate results, but when I paste the statement into NAB, it removes my "as hours" and then complains that I have no field named Hours. Here is the CTE:
HTML Code:
with storehours as ( SELECT @L$STR, listagg(trim( CASE @L$BCT WHEN 'A' THEN 'M-F' WHEN 'B' THEN 'Sat' WHEN 'C' THEN 'Sun' ELSE ' ' END concat ' ' concat @L$SE#),', ') within group(order by @L$STR, @L$BCT) as hours FROM myLib.myFile group by @L$STR )
Comment