x

Sorting based on Parameter values

Hi, I am using SSRS 2008R2.i have a jobid param in my report which is a textbox and i am passing some values like 1,4,2,6. i want the report to be sorted in the way i passed the values to the parameter. For example if i passed the jobid's as 3,2,5 the report should be sorted in 3,2,5 order only. if i pass jobid's as 3,1,2 the report should come in 3,1,2 order. please help me in this. Thanks in advance...
more ▼

asked May 08, 2012 at 12:38 PM in Default

sanjeev.matte gravatar image

sanjeev.matte
31 8 8 10

what are these numbers(1,4,2,6)? is that jobID or columns ordinals?
May 08, 2012 at 02:03 PM Cyborg
Those are the values that i am passing to JobId param.
May 08, 2012 at 02:35 PM sanjeev.matte
(comments are locked)
10|1200 characters needed characters left

1 answer: sort newest

I am not certain what you mean when you say you are passing the values to the parameter but if you are getting the values within TSQL then you could insert them into as temporary table and use the ID column in that table as the column to sort by ...

DECLARE @Sorting TABLE
    (
      ID INT IDENTITY ,
      MyVar INT
    )

INSERT INTO @Sorting
       ( [MyVar]
       )
       SELECT TOP 5 ABS(CHECKSUM(NEWID())) % 10 + 1
         FROM sys.COLUMNS

SELECT *
    FROM @Sorting AS s
    ORDER BY id

go

DECLARE @Sorting TABLE
    (
      ID INT IDENTITY ,
      MyVar INT
    )


INSERT INTO @Sorting
       ( [MyVar] )
    VALUES  ( 3 ),
         ( 6 ),
         ( 1 ),
         ( 2 ),
         ( 9 )


SELECT *
    FROM @Sorting AS s
ORDER BY id
more ▼

answered May 08, 2012 at 05:24 PM

Fatherjack gravatar image

Fatherjack ♦♦
42.8k 75 79 108

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x11
x10

asked: May 08, 2012 at 12:38 PM

Seen: 1013 times

Last Updated: May 08, 2012 at 05:24 PM