Skip to Content
0
Former Member
Nov 20, 2008 at 03:20 PM

sql case statement for parametes

17 Views

I am using sort parameters in the stored procedure

the following is my case statment

CASE When @SORT_1 = 'CUSTOMER'

Then ar_ivhdr_tbl.EN_CUST_KEY

When @SORT_1 = 'BILLTO'

Then ar_bill_tbl.ar_bill_name

Else ' ' END SORTKEY

what i would like to do is

have the sort key sort by 2 fields so instead of just the customer sort sorting the customer field

i would like it to sort customer and bill to

this is the syntax i tried but sql doesnt like it

CASE When @SORT_1 = 'CUSTOMER'

Then ar_ivhdr_tbl.EN_CUST_KEY,ar_bill_tbl.ar_bill_key

When @SORT_1 = 'BILLTO'

Then ar_bill_tbl.ar_bill_name, date

Else ' ' END SORTKEY

syntax issues, any ideas?