Quantcast
Channel: SQLServerCentral » Reporting Services » Reporting Services » Latest topics
Viewing all articles
Browse latest Browse all 2791

incrementing a variable in SSRS query (to define row position)

$
0
0
Hiusing MSVisual Studio 2008I'm trying to create an alias column called "row_number", for my where statement.for some reason the SSRS query is not incrementing.I have defined the parameter @num with a default value of 0. this works in mysql This is what I used in the SSRS dataset query , that doesn't workPlease advise how i can get this to work. thanks[quote]SELECT CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.REFERENCE AS REFERENCE,CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02,[b]@num = @num+1 as 'row_number'[/b]from CONSIGNMENT_TRACK_BUY_SUP_REFS_UNSjoin CONSIGNMENT_ALL_USER_DEFINES_UNS on CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.OPSREF$$ =CONSIGNMENT_ALL_USER_DEFINES_UNS.OPSREF$$where CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.OPSREF$$="ISL1600697"HAVING row_number = CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02[/quote]This works in mysql workbench [quote]set @num := 0;SELECT CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.REFERENCE AS REFERENCE,CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02,[b]@num := @num + 1 as row_number[/b]from CONSIGNMENT_TRACK_BUY_SUP_REFS_UNSjoin CONSIGNMENT_ALL_USER_DEFINES_UNS on CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.OPSREF$$ =CONSIGNMENT_ALL_USER_DEFINES_UNS.OPSREF$$where CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.OPSREF$$="ISL1600697"HAVING row_number = CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02[/quote]Example of SSRS parameter[img]https://social.msdn.microsoft.com/Forums/getfile/855309[/img]

Viewing all articles
Browse latest Browse all 2791

Trending Articles