Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,560,525
Community Members
 
Community Events
185
Community Groups

SQL SET @Variable not resolved correctly in WHERE statement with Table Transformer

Edited
Kamil Graczyk
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Mar 16, 2023

Hey Guys,
so basically I use this SQL statement to calculate the remainder of dividing the current week of the year by five:

SET @MYVAR = (FORMATDATE(GETDATE(), 'w') - (FLOOR(FORMATDATE(GETDATE(), 'w') / 5) * 5))

 

And when I try to use it with my table
eeee.png

Like this:

SELECT * FROM T1 WHERE 'person' = @MYVAR

It says "The query returned no rows."

What is the problem with that?
When I'm doing

SELECT @MYVAR FROM T1

It's resolved correctly.

1 answer

3 votes
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Mar 17, 2023

Hi @Kamil Graczyk ,

Maybe the following workaround will help your case:

Fri 12-1.png

Note that you will need the Table Toolbox macro to nest macros on Confluence Cloud.

Here are the settings of the internal Table Transformer macro:

Fri 12-2.png

SELECT *,
(FORMATDATE(GETDATE()) - FLOOR(FORMATDATE(GETDATE())/5)*5) AS 'weeks'
FROM T*

Fri 12-3.png

And here is the SQL query for the external Table Transformer macro:

SELECT 'value', 'person' FROM T*
WHERE 'value' = 'weeks'

Fri 12-4.png

Hope it will help your case.

Note that you've tried to compare numbers with the 'person' column that contains letters (strings). Seems that the 'value' is a correct field for the case.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events