2014年5月26日星期一

Consult written a sql statement , seeking Great God enlighten. Thank you , Online

now have a table GWSJ_YDLKJH, there is such a place "DD", the value of which he kept a " 432.2-435.6 " " 123.23-343.00 ", "1 #, 2 # ," and other types of characters
only in the above two types of data , there is only one intermediate array " - " and now I want the data in accordance with the " 123.23-343.00 " " 432.2-435.6 ", "1 #, 2 #" this sort of way , that put together the digital type , in accordance with the " - " in front of small to large numbers , followed by a # type into the back , so that how to write a sql statement , seeking great God enlighten. Thank you , Online
------ Solution ------------------------------------ --------

select * from (select * from test_order where dd like '%-%' order by dd) a
union 
select * from (select * from test_order where dd like '%#%' order by dd) b

------ Solution -------------------------- ------------------
What is your database ? sql area to ask it , there more professional
------ Solution ------------------------ --------------------
MySQL can do:
select * from GWSJ_YDLKJH order by instr (DD, '-') = 0, DD;
------ For reference only -------- -------------------------------
on upstairs union should be able to
---- - For reference only ---------------------------------------
2 floor can be
------ For reference only ----------------------------------- ---- wording
each database is not the same , if it is , then the second floor oracle can
------ For reference only ---------------------------------------
thank above . . .

------ For reference only ---------------------------------- -----

this seems not right , oracle database
------ For reference only ------------------ ---------------------
select to_number(substr(dd, 0, instr(t.dd, '-') - 1))as lc
  from GWSJ_YDLKJH t
 order by lc asc


everyone to see me this has not been optimized for
------ For reference only ------------------------- --------------
passing learn
------ For reference only ---------------------------------------
passing learn ! !

没有评论:

发表评论