DISTINCT with ORDER BY
All,
Facing a problem with the query below... "DISTINCT with Order By Clause.
His work when we take the same distinct column and order at this time where the query works. But in my case... There are a couple of b/w of joining tables... and are distinct for a column and the order is for a different table with a different column.
Please suggest me a solution for this below query column in the separate and column used for sorting are different.
SELECT DISTINCT gl_cc.segment2
OF gl_code_combinations gl_cc,.
per_all_people_f req_emp,
per_all_assignments_f req_emp_assign
WHERE req_emp.person_id = req_emp_assign.person_id
AND gl_cc.code_combination_id =
req_emp_assign.default_code_comb_id
AND req_emp.full_name = 'xyz '.
ORDER BY req_emp_assign.last_update_date DESC
Thank you
Problem will takes us to Basic!
Processing order for SELECT statements.
SQL query(Non recursive SQL) are processed in the following order
FROM clause
WHERE clause
GROUP BY clause
HAVING clause
SELECT clause
ORDER BY clause
So if you have something in the ORDER BY, but even not Fetch in SELECT it is bound to view the error.
Given THAT order will work on column projected by SELECT!
Single table query will fail also.
Select distinct ename in order by empno emp;
SQL error: ORA-01791: not a selected expression
01791 00000 - "not a selected expression.
* Cause:
* Action:
Inclusion of the req_emp_assign.last_update_date in the select column is necessary for order processing
Tags: Database
Similar Questions
-
Separate option is not allowed with Order By.
Hi all
I use a parameter in a query for a report like this:
Select Name, Id
of employees, emp_orders
where employees.id = emp_orders.id - table employees is the master
and (: order_type_id is null or)
((: order_type_id = emp_orders.order_type_id)) -: order_type_id is the user setting
order of employees.seq_no
the above query runs successfully but it doubles the data for employees with more than one order, if it has two orders, as it returns records for same twice and if it is of three that it returns the same records for three times!
I tried to fix it by putting the Distinct after select Word option, but in this case, it gives me this error:
ORA-01791: not a SELECTed expression
and when I remove the order by expression data duplication is gone like wanted!
How to solve the problem please? Thank you
Note: I use Oracle reports 6ihttp://ORA-01791.ora-code.com/
Separate option is not allowed with Order By.
Why
SQL> with t as 2 ( 3 select 1 id, 'str' str from dual union all 4 select 2 id, 'str' str from dual union all 5 select 1 id, 'str' str from dual 6 ) 7 select id, str from t 8 order by id, str 9 / ID STR ---------- --- 1 str 1 str 2 str SQL> SQL> with t as 2 ( 3 select 1 id, 'str' str from dual union all 4 select 2 id, 'str' str from dual union all 5 select 1 id, 'str' str from dual 6 ) 7 select distinct id, str from t 8 order by id, str 9 / ID STR ---------- --- 1 str 2 str SQL>
You can try to group by
SQL> with t as 2 ( 3 select 1 id, 'str' str from dual union all 4 select 2 id, 'str' str from dual union all 5 select 1 id, 'str' str from dual 6 ) 7 select id, str from t 8 group by id, str 9 order by id, str 10 / ID STR ---------- --- 1 str 2 str SQL>
-
Distinction with iPhoto Albums?
I have recently converted to pictures and there is a folder called iPhoto events that has all my old iPhoto albums events. Can I just drag these albums outside of this folder and put on my list of the albums separately and use them as any other album or is there a distinction with them. I have already learned about the distinction with smart albums, which do not count when I go try to find pictures that have not been assigned to any album (it's "Album is not a ' considers not assigned to a smart receiving photo album). I'm worried about the other distinctions that are not present in the Help menu that may affect these iPhoto created albums. Thank you.
They are just like any other album albums in a folder like any other folder
LN
-
Hi, I bought acrobat adobe pro ms with order number: 12287735659 but I have not received the download link and the serial numbers of adobe and had this message there is a problem processing your order, please contact our Service team customer to 800 448 1642 for assistance. my credit card is already loaded, but not received numbers.please series suggest
Hi Kunal,
If the problem still persists, can you please contact the support for this issue through https://helpx.adobe.com/support.html#/top_products.
Please do not hesitate to me message in person if assistance is needed.
Concerning
Stéphane
-
I already bought an Adobe Acrobat Pro DC with order number: 10617099159, but unfortunately, I made a mistake choosing the upgrade instead of the full version. I already made the payment of US$ 199.00. is there a chance to pay deference and get the full version stander? Please advise.
Do not worry, you must contact Adobe technical support, they will certainly check and assist you accordingly.
You can simply cancel this order and then to order the full version.
[Click the button still need help and select the Chat option.]
-
Hi all
I want to use rownum with order of clause-
When I use an order clause in the select query, I get so many lines that I don't want.
I have average-i want only two first rows according to the order of.
EG. - Select employee_id, salary of the order of salary employees;
EMPLOYEE_ID, FIRST_NAME SALARY
----------- -------------------- --------
132 2100 TJ
Steven 128 2200
2200 hazelnut 136
James 127 2400
135 Ki 2400
now, I just want to see the first two lines of the output above.
any oneone please help doesSQL> SELECT * FROM (SELECT employee_id, first_name, salary FROM employees ORDER BY salary) WHERE ROWNUM < 3; 2 3 4 5 6 7 EMPLOYEE_ID FIRST_NAME SALARY ----------- -------------------- ---------- 132 TJ 2100 128 Steven 2200
-
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
-
Hi all
Does anyone know if "in order to" has the priority on "updates"? In other words, by using the following query. Will be sorted first and then locked resulting lines or they will be locked everything first, and then sorted?
SELECT / * + cardinality (para. 1) use_nl (al t) * / NULL
LOOSE COLLECTION l_nullvalue_list
TABLE (i_list), my_table t Al
WHERE al.id = t.id
ORDER BY t.id
FOR the UPDATE OF t.id;
Any help is appreciated.
Kind regards
WFIt is the case that I do not speak:
drop table t cascade constraints purge; create table t as select rownum id, cast('x' as char(100)) pad from dual connect by level <= 10000; drop table t1 cascade constraints purge; create table t1(id int);
-- 1st session SQL> lock table t1 in exclusive mode; Table(s) locked
-- 2nd session declare type t1_type is table of rowid index by binary_integer; l_tab t1_type; begin execute immediate 'lock table t1 in share mode'; select rowid bulk collect into l_tab from t order by dbms_random.value for update; end; /
-- 3rd session declare type t1_type is table of rowid index by binary_integer; l_tab t1_type; begin execute immediate 'lock table t1 in share mode'; select rowid bulk collect into l_tab from t order by dbms_random.value for update; end; /
Now 2nd & 3rd sessions are blocked by the 1st. We will release the lock:
-- 1st session SQL> commit; Commit complete
2nd & 3rd sessions try to lock the rows of the table T, and fails one of the sessions with blocking:
declare type t1_type is table of rowid index by binary_integer; l_tab t1_type; begin execute immediate 'lock table t1 in share mode'; select rowid bulk collect into l_tab from t order by dbms_random.value for update; end; ORA-00060: deadlock detected while waiting for resource ORA-06512: at line 7
If you repeat the same scenario with ORDER BY id, then a session will wait to enqueue.
So, it's all on the order in which the row locks are acquired. -
Hello
I have a table with the data below, when I run my select with order option gives me
1 card
as a first line, but I need it
12 atm
as the first line, how this is possible.
create table test
(Identification number,
Val varchar2 (20)
)
insert into test values (1, 'Card')
Insert test values (2, ' map')
Insert test values (3, ' map')
Insert test values (4, 'cash')
Insert test values (5, 'Cash')
Insert test values (6, 'cash')
Insert test values (7, "Checque")
Insert test values (8, "Checque")
Insert test values (9, "Checque")
Insert test values (10, 'atm')
insert into test values (11, 'atm')
Insert test values (12, 'atm')
Select * from test
order by ASC of valOr try again with
select * from test order by upper(val) asc, id desc
-
Using distinct with an order of
Hi all
I'm not an expert SQL coder and I stuck with the following problem.
I have a table named Workorder that contains a set of commands. The orders including batch = 2 contain a mistake and this should be subject to new:
[ID] [WO_ID] [BATCH]
-----------------------------
1-10-2
2 10 1
3-20-2
Apparentely so it seems very simple, but when orders are represented things get complicated.
In the above query I need pickup - just - the following line:
[ID] [WO_ID] [BATCH]
-----------------------------
3-20-2
The following line must be excluded from the list:
[ID] [WO_ID] [BATCH]
-----------------------------
1-10-2
Because the WO_ID was later re-submitted successufully:
[ID] [WO_ID] [BATCH]
-----------------------------
2 10 1
So I need to fetch all work with a different one on WO_ID orders sorted by ID desc, so the separate line contains just the highest ID (the last decree submitted again).
I tried several ways, but I was not able to mix separate + order by.
Maybe it is also possible in some other ways?
Thank you very much
FrankSo you just need to wo_id, where there were No record with status = 1?
State 1 > is error, status = 1 is OK - and if there is at least one record with the State 1, this wo_id shouldn't be in the output?select wo_id from workorder group by wo_id having min(status_id) > 1 order by wo_id
The above won't give you a registration by wo_id.
And he selects only the wo_id, where the minimum value of batch is greater than 1 - in other words, there has been no record of success for this wo_id.If your condition is that the last record of a given wo_id must have the status > 1, then do it like:
select wo_id from workorder group by wo_id having min(status_id) keep (dense_rank last order by id) > 1 order by wo_id
-
Hello
I created a sub with sorting on a column request. (I have cutomized the IKM control append for order). I see the order by the State. If I use this (interface yellow) subquery in the main query (is also yellow interface) I do not see the order of condition
Subquery (Q-yellow interface):
Select
NEST,
START_TIME,
ACTION_TYPE_CODE
Of
(
SELECT DISTINCT
SERVICE_TRACKING_S.PID PID,
START_TIME TO_TIMESTAMP (TO_CHAR (SERVICE_TRACKING_S.ACTION_TIME, 'DD-MON-YY HH24:MI:SS'), "MON-DD-YY HH24:MI:SS"),
SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
of KSTGDB. SERVICE_TRACKING_S SERVICE_TRACKING_S
where (1 = 1)
ORDER BY-----------------------------------------------
NEST
START_TIME CSA
)
ODI_GET_FROM
Main query (Q1 - yellow interface):
Select
NEST,
START_TIME,
ACTION_TYPE_CODE,
RN,
RN_MAX
CEN
Select
Q.PID PID,
Q.START_TIME START_TIME,
WHEN Q.START_TIME - LAG(Q.START_TIME,1,Q.START_TIME) CASE above (PARTITION OF Q. PID ORDER OF Q.START_TIME) > numtodsinterval(75,'minute')
or Q.PID! = LAG (Q.PID, 1, 0) ON (Q.PID ORDER OF Q.START_TIME PARTITION) THEN 1 OTHER Q.ACTION_TYPE_CODE END ACTION_TYPE_CODE.
ROW_NUMBER() OVER(PARTITION BY Q.PID ORDER BY Q.START_TIME) RN,
Count (*) over (PARTITION OF Q.PID ORDER OF Q.START_TIME LINES BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING)
RN_MAX
de)
SELECT DISTINCT
SERVICE_TRACKING_S.PID PID, START_TIME TO_TIMESTAMP (TO_CHAR (SERVICE_TRACKING_S.ACTION_TIME, 'DD-MON-YY HH24:MI:SS'), "MON-DD-YY HH24:MI:SS"), SERVICE_TRACKING_S.ACTION_TYPE_CODE ACTION_TYPE_CODE
of KSTGDB. SERVICE_TRACKING_S SERVICE_TRACKING_S
where (1 = 1)
-I don't get stopped by here-
) Q
where (1 = 1)
) ODI_GET_FROM
Thanks in advance
KHello
what you trying to do? A decree by a subselect in the useless statement.
Also use an order you need to add an option and change the IKM
-
Impossible to reinstall OSX with order R-locked drive
I have a Yosemite running to the end of 2010 iMac. This morning after noticing the computer is slow, I went into disk utility, and I tried to check/repair permissions, and disk check and repair. I received the message that the drive contained errors and cannot be repaired.
I tried to re start the computer and that's when all the * broke loose! The mac gave me the gray screen with the Apple logo and the scroll bar, and then it shuts its self.
I restarted with R command and managed to start in recovery mode. I tried to reinstall the os x. I was informed that my drive has been locked. I did the search and tired to run some terminal commands.
/ usr/bin/chflags 0/volumes / *.
/ bin/chmod a + rx/Volumes / *.
Nope.
I tried to open disk startup (command + S?) and made some orders supplied in other threads. (see image). 'Volume 'Brian and Kristine' couldn't be checked completely.
I tried to use my WD MyBook Live machine and time to restore somehow, I forgot my password for hard drive... which is to save a file on the computer.
Ironically, I was planning on buying a new computer this week. I would like to see if I can record it to give to my son for school use.
Thoughts?
Thank you
Brian
This boot disk has failed. If you wish to continue using the Mac's hard drive needs to be replaced. They can't be repaired.
-
Need help with ordering high voltage
Hello
NI PCIe-6341 card is already installed. And I want to order a power supply voltage (CZE1000R) to generate the high voltage (DC). The goal is to fully control the high voltage. For example, the voltage can chang from zero to 30 kV in 5 or 10 seconds and be stable to 30 kV to 30 minutes and then go down smoothly at 20 kV in 5 minutes and finally back to zero. Could someone help me with this task? Thank you.
Hi, apok,
I used the 'panels-test' on 'measurement and automation explorer. And I see signals on an oscilloscope.
Thank your for your help.
But when I try to test the "tension cntrl.vi" it has not worked.
On the manual, he said:
"
Programming with external voltage:
Disconnect between TB1-2 and TB1 - 3 riders. Connect signal 0 - 10V between TB1-3 and TB1-6 (common)".
This means that I need to plug TB1 - 3 and TB1 - 6 and out of the acronym to TB1-3?
-
Problem with order submit data record for Reporting ATG
Hi, r. j. Nunes
I am facing problems with the connection to present newspapers for ATG of the report. The logs for RegistrationFileLogger, SiteVisitFileLogger, UserFileLogger, SegmentFileLogger were successfully getting generated but unable to see the logs for OrderFileLogger during shipment of the order.
I understand that the/atg/reporting/datacollection/trade/SubmitOrderEventListener of the listener must be notified so that the listeners of corresponding data is called in the order:
SubmitOrderEventListener-> OrderLogEntryQueueSink-> OrderLogEntryGenerator-> OrderFileLogger
and newspapers would be written.
But I'm not able to determine which component notifies the SubmitOrderEventListener by submitting an order.
Is - this SendFulfillmentMessage component? But SendFulfillmentMessage sends the message to the localdms topic: / local/realization/LocalSubmitOrder on the port of OrderSubmitPort which as component SubmitOrderEventListener listen the subject localdms: / local/realization/LocalSubmitOrder on the DEFAULT port?
Could someone please clarify.
Thank you
Saud
Hello
Pipelinelink = "sendFulfillmentMessage" name has been commented to our commercepipeline.xml that we did not use OOTB Presse. Once I removed the comment, sent messages and newspapers to submit order got generated.
Thank you
Saud
-
I had some problems with a po recipes.
I create a purchase order, but I can´t see it in some organizations. the ship of the organization is the main element of the organization.Sorry, I'm not a functional person so I can't offer much help.
You have consulted the documentation? -http://docs.oracle.com/cd/B53825_08/current/html/doclist.html#Purchasing_p
If you still have the same problem, then you can save a SR.
Thank you
Hussein
Maybe you are looking for
-
I've updated my site, but that is popping up again?
I updated the index.html file from my Web site and in other browsers that my newly updated site is displayed without doing anything to other browsers like Safari, but in firefox, the old site is still showing upward?
-
Satellite C660D - 18 c - need help with recovery
Hello I need help for my computer. My calculation is not started and shows "bootmrg is missing. I'm putting in recovery CD (i downloaded from Internet) when the CD starts, I get choose it to select the operating system, but it isn't here, what should
-
Xperia Z3 compact, no noise from the micro headphones wired
Xperia compact Z3, stock android 5.1.1 (later). Skype 6.3.0.503, 6.4.0.309 (later). No sound in Skype from my microphone when I'm on a wired headset. mobile phone calls, sip calls using the same helmet - no problem.
-
Can you explain what are the differencies between Photosmart series and PSC?
-
Original title: nvlddmkm.sys does not Just started having this couple weeks message. Killed or damaged at least one of my 9800 GT cards (SLI), which have been replaced under warranty. Who sets the part of the question of the display, but still cannot