example:
select * from t_cu where cno IN (
220,
120,
900,
350,
99,
1,
34
);
I would like to display the data in the same order as
220,
120,
900,
350,
99,
1,
34
=========================A
select * from t_cu where cno IN (
220,
120,
900,
350,
99,
1,
34
)
order by decode(cno,
220, 1,
120, 2,
900, 3,
350, 4,
99, 5,
1, 6,
34, 7,
8);
=========================B
SQL> ed
Wrote file afiedt.buf
1 with req as (select '7844,7698,7782,7499' as en from dual)
2 ,ord as (select REGEXP_SUBSTR (en, '[^,]+', 1, level) en, rownum rn
3 from req
4 connect by level <= length(regexp_replace(en,'[^,]*'))+1)
5 --
6 select emp.*
7 from emp join ord on (emp.empno = ord.en)
8* order by ord.rn
SQL> /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
=========================C
SQL> with t as (select t.*, rownum r
from table (sys.odcinumberlist (7788,
7934,
7782,
7902,
7369,
7499,
7566)) t)
select empno, ename
from emp e, t
where e.empno = column_value
order by r
/
EMPNO ENAME
---------- ----------
7788 SCOTT
7934 MILLER
7782 CLARK
7902 FORD
7369 SMITH
7499 ALLEN
7566 JONES
7 rows selected.
=========================
相关推荐
In a nonclustered index, the leaf level contains each index key, plus a bookmark that tells SQL Server where to find the data row corresponding to the key in the index. A bookmark can take one of two ...
When a customer creates a shopping cart and checks out the cart, the order data is stored in the ALL_ORDERS table. Assuming that the application needs to separate the newly created records and to be ...
Bug with QueryRecCount when ORDER clause contains CASE..END is fixed Bug with processing parameters on setting of an SQL query is fixed Oracle data provider Bug with using DATEADD function in ...
Support ticket 76423: ambiguous columns are now always qualified with their table/alias inside an ORDER BY clause 7.3.0.642 - 27th October Support for user account licensing (More info) 7.3.0.639 - ...
Syntax for CAST: CAST ( expression AS data_type [ (length ) ]) Syntax for CONVERT: CONVERT ( data_type [ ( length ) ] , expression [ , style ] ) 不带世纪数位 (yy) (1) 带世纪数位 (yyyy) 标准 输入/...
An intent lock indicates that SQL Server wants to acquire a shared (S) lock or exclusive (X) lock on some of the resources lower down in the hierarchy. For example, a shared intent lock placed at the ...
The foreign key in a table T1 _____ the same _____ as the corresponding primary key in table T2. must have, name need not have, name must have, domain (a) I, II, and III (b) I and II (c) ...
Combing the SQL WHERE Clause and the SQL ORDER BY Clause Performing Calculations in SQL Queries Using SQL Built-in Functions SQL Expressions in SQL SELECT Statements Grouping in SQL SELECT Statements ...
In order to continue using the products simultaneously, you should upgrade all of them at the same time. 7.1.4 29-Sep-17 InterBase data provider Bug with the "Input parameter mismatch" error for ...
SP-6847 : Added support for WITHIN GROUP order clause on STRING_AGG function. SP-6853 : Fix CTE/Cursor formatting error when automatically insert semicolons option is on. SP-6865 : 'Align data types ...
SQLDBDiff allow you : Ø Compare the structure of two SQL Server databases The following objects are supported : ...Add WHERE or ORDER BY clause. Ø Generate data synchronization scripts.
CHAPTER 4 SQL in a Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 4.2 Logging ...
Stored Programs as an Alternative to Expensive SQL Section 22.5. Optimizing Loops Section 22.6. IF and CASE Statements Section 22.7. Recursion Section 22.8. Cursors Section 22.9. Trigger ...
* In the Project Manager, units are incorrectly displayed in the order that they are listed in the USES clause, rather than alphabetically. * Using collections containing component references and ...
save and restore columns order and display width in ini-files and system registry; display icons for BLOB, memo, OLE and picture fields; select multiple records; convert columns headings to buttons. ...
sql> temporary tablespace temp quota 10m on data password expire sql> [account lock|unlock] [profile profilename|default]; <1>.查看当前用户的缺省表空间 SQL>select username,default_tablespace ...
MapInfo空间数据库建立 MapInfo空间数据库方案: 数据库:Oracle9i 数据上传工具:easyload ...use, this column must exist in order for MapX to correctly identify and apply record-level styles. NULL
orderby Clause 897 Ordering Using Method Syntax 897 Querying a Large Data Set 899 Aggregate Operators 902 Querying Complex Objects 905 Projection: Creating New Objects in Queries 909...
SQL>select sum(bytes)/(1024*1024) as "size(M)" from user_segments where segment_name=upper('&index_name'); 4、序列号 查看序列号,last_number是当前值 SQL>select * from user_sequences; 5、视图 ...
10.4.4. Queries in native SQL 10.5. Modifying persistent objects 10.6. Modifying detached objects 10.7. Automatic state detection 10.8. Deleting persistent objects 10.9. Replicating object between two...