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 ...
文件名中的"SqlServer-Parameterized-Query-With-IN-Clause-Cshar.pdf"可能是详细解释这一主题的文档,而"LogOn.aspx?rp=%2FKB%2Fdatabase%2F1276827%2FInClauseParam.zip&download=true"则可能指向一个包含更多示例...
PROC SQL and the SAS DATA step are two different methods for processing data in SAS, each with its own strengths and use cases: - **PROC SQL**: - **Strengths**: - Easier syntax for complex queries....
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 - ...
Oracle SQL查考手册是一部关于Oracle数据库查询语言的重要参考资料,它涵盖了运算符、表达式、条件、函数以及常见的SQL DDL(Data Definition Language)和Clause等内容。这篇总结将深入解析这些核心概念,帮助读者...
- **Checking That the Dates Are in the Proper Order**: Describes how to ensure that dates are in the correct order across multiple files. #### Double Entry and Verification (PROC COMPARE) This ...
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 ...
- subqueries in the "from" clause:在FROM子句中嵌套查询,用于复杂的数据检索。 - grouping, aggregation, and having clauses:通过GROUP BY进行分组,使用AGGREGATE函数(如SUM, AVG)进行聚合,HAVING子句则在...
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 ...
p_where_clause IN VARCHAR2, p_data OUT SYS_REFCURSOR ) AS BEGIN OPEN p_data FOR SELECT * FROM (SELECT A.*, ROWNUM RN FROM (SELECT /*+ FIRST_ROWS(p_page_size) */ * FROM p_table_name WHERE p_...
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 ...
- `WHERE clause`: 用于过滤查询结果,只返回满足条件的记录。 11. **去除重复记录** - `DISTINCT`: 在查询结果中去除重复记录。 12. **函数和表达式** - `NVL(expression, default_value)`: 如果expression为...
此外,书中还详细介绍了各种提示(Hints)、子句(Clauses)和其他语法结构,如JOIN Hints、Query Hints、Table Hints、OUTPUT Clause、SEARCH Condition、GROUP BY、HAVING、INTO Clause、ORDER BY、OVER Clause、...
- `SELECT column_name, SUM(column_name) OVER (ORDER BY column_name ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS rolling_sum FROM table_name;` #### Table Value Constructor 表值构造器用于创建临时表,...
- `FOR quarter IN (q1_sales AS 'Q1', q2_sales AS 'Q2', q3_sales AS 'Q3', q4_sales AS 'Q4')`指定了原列中的值以及对应的季度名称。 ##### 3.4 注意事项 - `UNPIVOT`操作同样支持使用`WITH`子句来创建临时表或...
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.