I try to sort the machine number ascending. If I took out the Prduct description then the machines are sorted ascending. I would like to show the Product description for every machine and I would like to show the machines sorted(M101,M102,M103...)
where Date BETWEEN @StartDateTime AND @EndDateTime
and Name in ('M101','M102','M103','M104','M105','M106','M107','M108','M109','M110', 'M111')
group by Date, Name, ProductName
) as s
order by Name asc
It should look like this here:
[![enter image description here][4]][4]
I have try these 2 solution
first use case when in ORDER BY clause like this
ORDER BY CASE
WHEN name = 'M101' THEN 1
WHEN name = 'M102' THEN 2
END
It's not best solution but it's can solved your problem and second solution is use substring in order by clause like this
ORDER BY CAST(SUBSTRING(name,2,10) AS INT)
And if you use Column group for dynamic expand column don't forget delete delete sorting condition. Hope it's help
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.