问题描述
假设我写了一个查询:从员工中选择员工,其中employeeid在(2,3,5,1)
然后我想根据2,3获取数据,5,1订单。但它显示1,2,3,5明智请帮帮我?
选择m.MachineID,求职码,故障,运行,FaultLimitExceed,ProdCount来自机器管理员m内部加入machinestatuspara s+on m .machineid = s.machineid其中m.machineid不为null且m.machineid为(2,1);
ans:
'1','1','0','0','0','2377','00:57:42','31 -10-2014'
'2 ','3','0','0','0','1492','00:57:35','31 -10-2014'
但我想要
'2','3','0','0','0','1492','00:57 :35','31 -10-2014'
'1','1','0','0','0','2377','00:57:42' ,'31 -10-2014'
suppose i wrote query :select employees from employee where employeeid in(2,3,5,1)
then i want to fetch data according to 2,3,5,1 order. but it display 1 ,2,3,5 wise please help me?
"select m.MachineID,jobcode,Fault,Running,FaultLimitExceed,ProdCount from machinemaster m inner join machinestatuspara s " +" on m.machineid=s.machineid where m.machineid is not null and m.machineid in(2,1)";
ans:
'1', '1', '0', '0', '0', '2377', '00:57:42', '31-10-2014'
'2', '3', '0', '0', '0', '1492', '00:57:35', '31-10-2014'
but i want
'2', '3', '0', '0', '0', '1492', '00:57:35', '31-10-2014'
'1', '1', '0', '0', '0', '2377', '00:57:42', '31-10-2014'
推荐答案
Please use below example, it's helpful for you.
<pre lang="sql">create table #temp
(
empid int
)
insert into #temp(empid) values(1)
insert into #temp(empid) values(2)
insert into #temp(empid) values(3)
insert into #temp(empid) values(5)
select * from #temp order by empid%2</pre>
这篇关于以格式提取数据的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!