sys_context and order by clause
Hi allIM using Oracle 11 g R2.
Is it somehow possible to use the context variable (to store the column name) in the ORDER BY clause? My ultimate goal is to build by Order at run time, without using the concatenation.
for example, I created context as my_ctx for some pkg and its variable as v_ctx with a value defined as 'TABLE_NAME '.
So it is possible to use it as
Select * from all_tables
sys_context order ('my_ctx', 'v_ctx');
If not, does perform a work around?
Thank you
Vivek
Hi, Vivek,
Vivek says:
Hi allIM using Oracle 11 g R2.
Is it somehow possible to use the context variable (to store the column name) in the ORDER BY clause? My ultimate goal is to build by Order at run time, without using the concatenation.
Of course, you can use SYS_CONTEXT in an ORDER BY clause, but it is unclear what you are trying to do, so I don't know if SYS_CONTEXT will help you.
for example, I created context as my_ctx for some pkg and its variable as v_ctx with a value defined as 'TABLE_NAME '.
So it is possible to use it asSelect * from all_tables
sys_context order ('my_ctx', 'v_ctx');If not, does perform a work around?
Post a full test script Hat people can run to recreate the problem and test their ideas. Show the output you want from the parameters a data you give.
Consider using a CASE expression in the ORDER BY clause. You can use SYS_CONTEXT in the expression BOX, if you wish.
Tags: Database
Similar Questions
-
Hello
I ask the County in the query1 and the same registration query 2, the output I'm getting is the same except for the last one.
Kindly help me in setting the same.
********Query1******** select * from ( select ci.name "Name",count(1) "Total" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID=sg2.PARENT_SUPPORT_GROUP_SEQ_ID) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id and t.task_type = 'Incident' and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID --and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-Mon-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:59','DD-Mon-YYYY,HH24:MI:SS') group by ci.name order by 2 desc) where rownum <= 5; *****Output***** Name Total EWHEBIP1 6 EUEODSD1 2 EUEOLTP8 2 HOUORD22 2 GIBIX-EUEOLTP8 1 *******Query2******** select ci.name "Current CI", t.priority "Priority", to_char(t.task_number) "Incident ID", t.short_description "Description", to_char(OP.EST_ACTUAL_END_DATETIME,'DD-MON-YYYY,HH24:MI') "Deadline", op.ACTUAL_DUR_HOURS_INTEGER "Acutal Dur Hrs", sg.name "Work Group Name" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID=sg2.PARENT_SUPPORT_GROUP_SEQ_ID) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id and t.task_type = 'Incident' and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID --and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-Mon-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:59','DD-Mon-YYYY,HH24:MI:SS') and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and ci.name in ( select name from (select ci.name, count(1) "Total" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID=sg2.PARENT_SUPPORT_GROUP_SEQ_ID) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id --and sg.search_code = p_target_name and t.task_type = 'Incident' and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID --and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-MON-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:00','DD-Mon-YYYY,HH24:MI:SS') group by ci.name order by 2 desc) where rownum <=5) order by 1 desc; ******Output********* Current CI Priority HOUORD22 2 - Urgent (1 business day) HOUORD22 2 - Urgent (1 business day) EWHEBIP1 3 - Normal (3 business days) EWHEBIP1 2 - Urgent (1 business day) EWHEBIP1 2 - Urgent (1 business day) EWHEBIP1 2 - Urgent (1 business day) EWHEBIP1 2 - Urgent (1 business day) EWHEBIP1 2 - Urgent (1 business day) EUEOLTP8 3 - Normal (3 business days) EUEOLTP8 2 - Urgent (1 business day) EUEODSD1 2 - Urgent (1 business day) EUEODSD1 3 - Normal (3 business days) DMS-GENERALMETHODS 2 - Urgent (1 business day)
Maybe
select * from (select ci.name "Name", count(1) "Total" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID = sg2.PARENT_SUPPORT_GROUP_SEQ_ID ) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id and t.task_type = 'Incident' and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID -- and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-Mon-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:59','DD-Mon-YYYY,HH24:MI:SS') group by ci.name order by 2 desc,1 /* order by name too */ ) where rownum <= 5; -- @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ select ci.name "Current CI", t.priority "Priority", to_char(t.task_number) "Incident ID", t.short_description "Description", to_char(OP.EST_ACTUAL_END_DATETIME,'DD-MON-YYYY,HH24:MI') "Deadline", op.ACTUAL_DUR_HOURS_INTEGER "Acutal Dur Hrs", sg.name "Work Group Name" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID = sg2.PARENT_SUPPORT_GROUP_SEQ_ID ) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id and t.task_type = 'Incident' and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID -- and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-Mon-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:59','DD-Mon-YYYY,HH24:MI:SS') and ci.name in (select name from (select ci.name, count(1) "Total" from tsgdw_task@awhsncp1 t, tsgdw_operational_process@awhsncp1 op, tsgdw_support_group@awhsncp1 sg, tsgdw_person@awhsncp1 p, tsgdw_configuration_item@awhsncp1 ci where sg.SUPPORT_GROUP_SEQ_ID in (SELECT sg2.SUPPORT_GROUP_SEQ_ID FROM tsgdw_support_group@awhsncp1 sg2 start with sg2.SEARCH_CODE = 'DBNONEC' --p_target_name connect by prior sg2.SUPPORT_GROUP_SEQ_ID = sg2.PARENT_SUPPORT_GROUP_SEQ_ID ) and t.task_seq_id = op.task_seq_id and sg.support_group_seq_id = op.support_group_seq_id and op.assigned_person_seq_id = p.person_seq_id -- and sg.search_code = p_target_name and t.task_type = 'Incident' and t.priority in ('0 - Immediate (2 hours)','1 - Critical (4 hours)','2 - Urgent (1 business day)','3 - Normal (3 business days)') and op.CLOSE_CONFIG_ITEM_SEQ_ID = ci.CONFIGURATION_ITEM_SEQ_ID -- and OP.EST_ACTUAL_END_DATETIME between ??EMIP_BIND_START_DATE?? and ??EMIP_BIND_END_DATE?? and OP.EST_ACTUAL_END_DATETIME between to_date('01-Apr-2012,00:00:00','DD-MON-YYYY,HH24:MI:SS') and to_date('08-Apr-2012,23:59:00','DD-Mon-YYYY,HH24:MI:SS') group by ci.name order by 2 desc,1 /* order by name too */ ) where rownum <= 5 ) order by 1 desc;
Concerning
Etbin
-
Explicit cursor and Order by clause
Dear Oracle experts,
I am facing a strange situation:
SQL > DECLARE
2 CURSOR c_1
3 EAST
4 (SELECT 1 FROM DUAL to 1);
5. start
6 NULL;
7 end;
8.
(SELECT 1 FROM DUAL to 1);
*
ERROR on line 4:
ORA-06550: line 4, column 27:
PL/SQL: ORA-00907: lack the right parenthesis
ORA-06550: line 4, column 7:
PL/SQL: SQL statement ignored
But:
SQL > DECLARE
2 CURSOR c_1
3 EAST
4. SELECT 1 FROM DUAL;
5. start
6 NULL;
7 end;
8.
PL/SQL procedure successfully completed.
SQL > START
2 FOR an IN (SELECT 1 FROM DUAL BY 1)
LOOP 3
4 NULL;
5 END OF LOOP;
6 END;
7.
PL/SQL procedure successfully completed.
This means that I can't use ORDER BY explicit cursor? Or there is another logical explanation?
Thanks in advance.
No, it means that you can have an order by parentheses unless it is part of the outer query.
declare
Cursor c_1
is
Select 1
of the double
order by 1;
Start
null;
end;
/
will work, as well as
declare
Cursor c_1 is
Select *.
(select 1
of the double
order by 1);
Start
null;
end;
/
-
without the use of order by and connect by clause
Hi all
can I write a tree query without using a start with clause and connect by clause
and
can I order the names used in a select query without using the order by clause
those things are possible in the select...dipuna wrote:
Hi allcan I write a tree query without using a start with clause and connect by clause
I think that no.
can I order the names used in a select query without using the order by clause
No.Why you do not want to use order by clause?
-
order by clause and index access
Hi all
I have tried under request.
SELECT e.employee_id, e.department_id
E EMPLOYEES
order by 2;
Implementation plan...
SELECT STATEMENT, GOAL = ALL_ROWS 4 107 856
SORT ORDER BY 4 107 856
TABLE ACCESS FULL EMPLOYEES OF HR 3 107 856
Below query Oracle by using the INDEX FULL SCAN. I'm not able to find an appropriate explanation. Pls how me oracle optimizer include order by clause while to fetch documents.
-departmentId has index EMP_DEPARTMENT_IX, which is the normal index.
SELECT e.employee_id, e.department_id
E EMPLOYEES
order by 1;
SELECT STATEMENT, GOAL = ALL_ROWS 3 107 856
TABLE ACCESS BY INDEX ROWID HR 3 107 856
INDEX FULL SCAN HR EMP_EMP_ID_PK 1 107
Thank you.Consolidation of the index factor is used by the CBO to calculate how much is a scan interval index (the one that is followed by a table-access by rowid) for this index will be. The CBO calculates this option to select an index if two or more paths index are available.
But it could also be used to decide between choosing a full index scan (to honor an order by clause and without having to sort after the scan) in the course of a full table scan that requires an extra sort (in honor of the order by clause) operation.There are many articles talking about this:
http://www.oaktable.NET/category/tags/clustering-factor
http://Oracle-Randolf.blogspot.com/2010/01/clusteringfactor-what-if-analysis.html
http://mehrajdba.WordPress.com/2009/02/09/index-clustering-factor/
I just realized today that in case you described: If department_id column is NULL-able, Oracle cannot use the index in department_id to honor the order by clause, because he would find all the lines (those with an id of NULL service), in this case.
-
How to remove the Order By clause
How can I get rid of the Order By clause in the underlying SQL query? I created a simple hierarchy, but when I use the hierarchy in the analysis and then come down, the results show multiple occurrences of each child. For some reason, I was able to reduce the number of occurrences of each child by adding a saved filter.
I was expecting this:
Instead, I got this:
The generated physical query looks like this:
SET VARIABLE QUERY_SRC_CD = "report"; SELECT s_0, s_1, s_2, s_3, s_4 s_5, (FROM s_6)
SELECT
s_0 0,.
CAST (NULL AS VARCHAR s_1 (1)).
"Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.
'All the colleges' s_3,.
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").
MOUNT s_5 (NULL AS DOUBLE),
"Registration - College". "" Counties of schooling. "" Full-time student "s_6
"REGISTRATION - College".
UNION ALL
SELECT
1 s_0
"Registration - College". «Dimensions of the inscription '.» "" Name of College "s_1,.
"Registration - College". «Dimensions of the inscription '.» "' Exercise ' s_2,.
'All the colleges' s_3,.
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_4 all Colleges").
IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". ("' S_5 College ').
"Registration - College". "" Counties of schooling. "" Full-time student "s_6
"REGISTRATION - College".
WHERE
("Registration - College". «Dimensions of the inscription '.» ("' Exercise ' IN ('201213')) AND (IDOF ("registration - College". «Hierarchies of the inscription '.» "College". ". (("' Colleges ') (1))
) djm ORDER OF 1, 3 ASC NULLS LAST, 4 ASC NULLS FIRST, 5 ASC NULLS FIRST, 2 ASC NULLS FIRST, NULLS FIRST CSA 6
EXTRACT FIRST 10000000 LINES ONLY
HI mbengue,.
Check the report you are running any column presentation sorted in the user interface (in which case the order by clause will creep into generated sqls Physics). Also, I think that its worth it to check the settings of the hierarchy you have configured and if the installation program for the calculation of the measured column (number of students in this case), has been done correctly.
Kind regards
Arko
-
Hello
I want to know what it means when I use the "order by" clause with more than one column in both cases (sort order, it's the same, and when the sort order is different), for example
What should happen when I do this
1 Select * from table
order by 1, 2; -both are a CSA
2 - Select * from table
order by 1 asc, desc 2;
in both cases if it sorts the column with the first column without worrying, it is asc or desc, order another column order, because he should get
related data in the first column, then another sort column does nothing?
Am I wrong?
Thank you
SQL > select * from t by col1, col2 CSA CSA;
COL1 COL2
-------------------- --------------------
1 1
1 2
1 3
2 1
2 2
SQL > select * from t by CSA col1, col2 desc;
COL1 COL2
-------------------- --------------------
1 3
1 2
1 1
2 2
2 1
-
Cannot wrap a select with order by clause in a file.
TOGETHER SET TERMOUT OFF FEEDBACK OFF PAGESIZE 0 400 LINESIZE ECHO OFF OFF POSITION
coil & 1;
Select "EMPID, EMP_NAME, REGION, FROM, TO, MONTH, ACTIVITY_TYPE, PROJECT_PIN, MILESTONE_NAME, PRACTICE_ID, RESOURCE_CATEGORY, HOURS, COMMENT, percent ALLOCATION, INVOICE_TO, the STATE of the double"
Union of all the
select empid,resource_name,region,week_of,(week_of+7),core_month,bill_rate,project_name,project_type,milestone_name,practice_id,resource_category,total_hours_submitted,project_type,"%ALLOCATION",invoice_to,status from master_emp_allocation order by week_of;
spool off;
"exit";
/
the above block gives result below
select empid,resource_name,region,week_of,(week_of+7),core_month,bill_rate,project_name,project_type,milestone_name,practice_id,resource_category,total_hours_submitted,project_type,"%ALLOCATION",invoice_to,status from master_emp_allocation order by week_of
*
ERROR at line 3:
ORA-00904: "WEEK_OF": invalid identifier
---------------------------------------------------------------------------
Without the order by clause it wraps the file passed as an argument.
check
Combining the UNION AGENDA and BY
Columns in the ORDER BY list must be a subset of the columns in the selection list on the left side of the union.
All the columns in the ORDER BY list should be sorted in ascending order, and they must be a prefix in the order of the columns in the target of the left side of the UNION list.
-
I have a very basic SQL statement that I am running on a simple table of three columns. I just want to choose two of the three columns basing selection on a column, then rank each other. I use version 9.2.0.1.0 and I tried to use sqlplus and toad 10.6 and the results are the same in both. My problem is that even if I use an Order By clause the results not be sorted. I have countless statements written and never had a problem with the Order By clause before. I'm puzzled.
Executed SQL statement:
Select COL3 From Table1 where COL2 = 1 Order By COL3;
Result:
DXXXXX
NXXX Mxxx/Cxxxx CXXV
Nzzzz Ezzzz
Oxxxxxxxxxx Exxxx
Rxxxxxxxxx Exxxx
Sxxxxxxx Exxxx
Sxxxxxx Hxxx
gxxxxxxxYou should know that I replaced everything except the first letter of each letters to alter woth Word. There's nothing remarkable about the table:
Executed SQL statement:
DESC Table1;
Result:
Table1 TABLE:
Name Null? Type
----------------------------------------- -------- ----------------------------
COL1 NUMBER
COL2 NUMBER
COL3 VARCHAR2 (255)Hello
Use this...
Select COL3 From Table1 where COL2 = 1 Order By LOWER (COL3);
It should work once you order by the case-based.
When you view, its up to you, if you want to use all the conversions of case or not
-
ORDER BY clause with an expression
As the column of names and table name is valid, what happening internally when the query is executed?
SQL > SELECT STU_ID, STU_NAME FROM to STUDENT BY 2 + 3, STU_ID;
What I discovered, was that the lines get sorted by ascending order of STU_ID. It is obvious that he does not know the expression 2 + 3, so my doubts are:
(a) is he adding a pseudo-column to the table with 2 + 3 get discounted at 5?
Select (b) if there is a 5th column among students of the table and specify us it in the select statement of the list (5 column names) then why not consider as 5 and sort the data according to that?
(c) it is true that, any expression that we write is getting evaluated to null? Then - what is ORDER BY NULL refers to any order and if the Analyzer search name column or next position (if specified)?
(d) If neither of the two, so what is the reason of ignorance?Hello
Welcome to the forum!
987236 wrote:
As the column of names and table name is valid, what happening internally when the query is executed?SQL > SELECT STU_ID, STU_NAME FROM TO STUDENT BY 2 + 3, STU_ID;
What I discovered, was that the lines get sorted by ascending order of STU_ID. It is obvious that he does not know the expression 2 + 3, so my doubts are:
b is a pseudo-column adding to the table with 2 + 3 get discounted at 5
There is no column pseduo involved. (Pseudo-colonnes are something that Oracle provides to you, without requiring you to specify what you want. Include ROWID and LEVEL pseudo-colonnes. In this example, 2 + 3 is an Expression . Like the pseudo-colonnes, expressions can usually appear in the ORDER BY clause, even if they are not actually stored in the table.)
It is the first sort by the NUMBER 5 (= 2 + 3), not the 5th column. Since the NUMBER 5 has the same value on every row, every row relates to the forefront. The result of sorting by any constant is the same; the results are the same that besides as exrpression in the ORDER BY clause. This is the clause ORDER BY, that you have published is equivalent toORDER BY 2 + 3 , 'foo' , SYSDATE , NULL , stu_id
and this is also equivalent to
ORDER BY stu_id
None of the expressions except stu_id vary from one line to the other, then none of them affect sorting.
Select (b) if there is a 5th column among students of the table and specify us it in the select statement of the list (5 column names) then why not consider as 5 and sort the data according to that?
As Solomon replied only literal numbers are taken to refer to a column. 5 is a literal number, then
ORDER BY 5
means "Sort by the 5th column", but 2 + 3 is not a literal (that is an expression that happens to include a couple of literals), so
ORDER BY 2 + 3
does not refer to the 5th colunmn.
(c) it is true that, any expression that we write is getting evaluated to null? Then - what is ORDER BY NULL refers to any order and if the Analyzer search name column or next position (if specified)?
No, when you way "ORDER BY x", the rows with values of x which come first, followed by the lines with higher values of x. lines having the same value of x will be together, in no particular order with respect to the other (unless there is an expression of failure later in the clause ORDER BY.
This is exactly what happens when you say "ORDER BY NULL". NULL has the same value (in fact, the same lack of any value) on all lines, so all rows have the same value of x, and they will appear in no particular order.(d) If neither of the two, so what is the reason of ignorance?
-
any case when and the sql clause
Hello:
What follows is my sql clause:
SELECT T.*, b.name
OF dbtest1 t
LEFT OUTER JOIN dbtest b ON t.NO = b.empno
WHERE t.ChineseName like '% "| : ChineseName | ' %' AND b.name like "%" | : name | » %'
ORDER BY t.ChineseName
The main problem is that I want to check the b.name if it is null, it can be passed as function NVL, so I try using case when, but it does not work.
When there are the b.name in where clause, the columns of result will not include data without b.name (or implies the b.name is NULL); And that
the result data are not entirely accurate.
is it possible to use the case when it is implemented in the following code snippet:
-case when b.name is not NULL then b.name like "%" | : name | » %'
Else b.name = NULL (b.name = b.name does not seem to work on the analysis of data zero)
end
Thank you very much.962769 wrote:
The main problem is the table is the form of the cross, and the like clause will filter the
data without a name. Basically, it should show the empty columns, however, it won't.
so, when I test the sql code, I fhound Like "%" | b.Name | ' %' will not get the data when the original dbtest1 table data
has no id corresponding to the BD test. It seems pointless to go the LEFT OUTER JOIN.Thank you
WHERE t.ChineseName like '%'||:ChineseName||'%' AND ( b.name like '%'||:name||'%' or b.empno is null )
-
Does anyone know how or where to enter in the ORDER BY clause when you use a SQL data source in a load rule? I prefer to do the classification in the State of charge rather than create a view on the side of the DB for this if possible.
According to the documentation "box of the SQL statement in Open SQL Data Sources dialog box provides Select, From, and where areas of text that helps you write SQL queries." You can specify multiple data sources, filter the display of folders and specify how the records displayed in the data editor Prep are classified and grouped. "but I have not found anywhere where you can order or group data. I don't need to be able to group data I want to just be able to control my data to make the most effective possible charging process.
I sort the data by inserting into the table of load, but Oracle is not necessarily insert the records in the table according to their order when you go.
We're currently on 11.1.1.3 Essbase and Oracle 11 g.
Any help is greatly apprecied.Just nail it on your WHERE clause in the area WHERE the. I think that you can even stick the entire statement (under the keyword "SELECT") within the area of SELECTION.
-
Hai all,
I have problem with order by clause,
My query is
"Select number from table1 order number CSA.
and the output as
1
10
12
13
15
17
19
2
20
21
22
.
........
But if we give the order that it should display below the only good?
1
2
10
12
13
15
17
19
20
21
22 ........
Help me please why it is not displayed as she. and how to make the statement to display as in the second case. Thanks in advance.
Kind regards
UrajaIn your table, the column is VARCHAR2 data type.
It is a string, even if it is to store numeric values, it will get condemn as strings
Try the below
select your_column from table1 order by to_number(your_column) asc
Published by: JAC on November 19, 2012 16:35
-
order by clause union in date column
Hi gems... good evening...
Oracle version: 11.2.0.2 EL6 Linux server
I have a query as below:
Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions
Union
Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions
Union
Select col1, col2, col3 col4
tab1, tab2, tab3
where the conditions;
Now the col4 is a date column, and I need to order by on that entire result sets. I know that I can do (order of col4) (order by 4) or at the end of all of the query.
But the problem is that the output is coming to Mon-dd-yyyy (i.e. 31-Dec-2012).
I want each output in the format dd/mm/yyyy, so I need to use the function to_char.
But in this case, I can't use the order by clause, because in this case it's get organized by character IE by 1,2,3,4,5 like that.
How can I solve my problem... Please help... Thanks in advance.
Published by: gogol on 3 November 2012 08:05Maybe - when you order by date column, she did it with a date internal representation so on exit you can use any date format you think appropriate
select distinct col1,col2,col3,col4 from (select col1,col2,col3,col4 from tab1,tab2,tab3 where conditions_1 or conditions_2 or conditions_3 )
Concerning
Etbin
-
Purpose of the ORDER BY clause in the analytic function Min Max
I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.user10566312 wrote:
I was always using analytical functions like Min Max without ORDER BY clause. But today I used with the ORDER BY clause. The results are very different. I would like to know the purpose of the ORDER BY clause in Min, Max and analogues of analytical functions.It is a good point that many developers are not so aware. As far as I understand it the way it works.
Some analytical functions do not need an order by or windowing clause (SUM, COUNT, MIN, etc.). If there is no specified window, then the full score is the window.
As soon as you add a command also add you a windowing clause. This window has the default value of 'rank ofrowsbetween unbounded preceding and current_row. So as soon as you add an order by clause, you get a sliding window.Documentation: http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions001.htm
windowing_clause
...
You cannot specify this clause unless you specified the order_by_clause. Window limits defined by the clause RANGE you can not specify only a single expression to the > order_by_clause. Please refer to 'Restrictions on the ORDER BY Clause'.example of
with testdata as (select 10 numval, level lv from dual connect by level < 10) select lv, numval, sum(numval) over () sum1, sum(numval) over (order by lv) sum2 from testdata; LV NUMVAL SUM1 SUM2 -- ------ ---- ---- 1 10 90 10 2 10 90 20 3 10 90 30 4 10 90 40 5 10 90 50 6 10 90 60 7 10 90 70 8 10 90 80 9 10 90 90
Published by: Sven w. on 25 Sep 2012 16:57 - default behavior has been corrected. Thanks to Chris
Maybe you are looking for
-
I got a XP computer for free and you want to reregister in my name. How do I do that? Thank you.
-
How to change tables of waveforms?
Hi, I hope you can help with this. I read 6 channels of analog data to a USB - 6008 1000 samples/second, 1000 sample blocks in a loop. The data come from DAQMX as an array of 6 waveforms. I want to (y) scale all data such as 0, 1, 2 channels are divi
-
The substitution of password on the windows Vista Welcome screen
has windows vista installed on laptop, now I just can't past the logon page - keeps asking for a password under my daughters name and she doesn't know what she put, the screen does not even to change username - what can I do
-
Help, please
-
Hello I have improved my z10 to 10.3.1 yesterday. I tried to send an email with an address that was never in my contacts list, the new email address that I entered turned to red and the stay of the button 'Send' in gray, I couldn't send the email. Bu