Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

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

$
0
0

Hi

using MSVisual Studio 2008

I'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 work

Please advise how i can get this to work. thanks


SELECT

CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.REFERENCE  AS REFERENCE,
CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02,

@num = @num+1 as 'row_number'

from CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS

join 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



This works in mysql workbench 

set @num := 0;


SELECT

CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS.REFERENCE  AS REFERENCE,
CONSIGNMENT_ALL_USER_DEFINES_UNS.USER_DATA_NUMERIC_02,
@num :=  @num + 1 as row_number

from CONSIGNMENT_TRACK_BUY_SUP_REFS_UNS

join 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




Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>