Sorting in dataGrid

S

simon

I have column of dataType varchar(10).

The values in this column are decimal numbers, 'NUL', OR ''.
(because of 'NUL' and '' values I haven't defined column as decimal(18,2))

When I fill dataGrid and user click sorting on this column, the column is
sorted alphabetically.

So 100,00 is before 2,00.

Is there any option to include somehow, custom sorting, which exclude the
'NUL' and '' fields and sort other fields like numbers?

Thank you for your answer,
Simon
 
G

Guest

Hi Simon,

Suppose the column name is charNum, you can use following query

SELECT * FROM TABLE_NAME
ORDER BY (CASE WHEN charNum IS NULL OR charNum ='' THEN Big_Number ELSE
CAST(charNum AS DECIMAL(18,2)) END)

HTH

Elton Wang
(e-mail address removed)
 
S

simon

Thanks Elton,

that would be one solution.

Other is that I create invisible column in datagrid, which is decimal
dataType and use order by that column.

regards,
Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,280
Latest member
BGBBrock56

Latest Threads

Top