Query to find the distinct values
Hi all
Given, it's like
with t as (select 1 eno, "AC_ACCOUNT" the double job_id)
Union select 2 eno, 'AC_ACCOUNT' job_id of the double
Union select 3 eno, 'AC_ACCOUNT' job_id of the double
Union select 4 eno, 'AC_MGR' job_id of the double
Union select 5 eno, 'AD_VP' job_id of the double
Union select 6 eno, 'AC_MGR' job_id of the double
Union select 7 eno, 'AC_MGR' job_id of the double
Union select 8 eno, "FI_ACCOUNT" double job_id)
Select * from t;
It takes the job_id not duplicated output.
For this release of data should be,
AD_VP
FI_ACCOUNT
Is it possible to write a query without hard coding or using separate?
Kind regards
SoundariyaKumar.R
Hello
You could do like:
SQL >
SQL > with t as (select 1 eno, "AC_ACCOUNT" the double job_id)
2 union select 2 eno, "AC_ACCOUNT" double job_id
3 union select 3 eno, "AC_ACCOUNT" double job_id
4 union select 4 eno, "AC_MGR" double job_id
5 union select 5 eno, "AD_VP" double job_id
6 union select 6 eno, "AC_MGR" double job_id
7 union select 7 eno, "AC_MGR" double job_id
8 union select 8 eno, "FI_ACCOUNT" double job_id)
9 select job_id from group by job_id t having count ()) = 1;
JOB_ID
----------
AD_VP
FI_ACCOUNT
SQL >
Tags: Database
Similar Questions
-
Query to find the 2 values in column 1
Hello
I have a table like
The user enters 2 values, for example A10Q and A10R. I don't need only the records that have the two values.create table table1 (col1 NUMBER, col2 VARCHAR2(4), col3 varchar2(4)); Sample Data: select COL1, NVL(COL2,'---') col2, NVL(COL3,'---') col3 from table1; COL1 COL2 COL3 ---------------------- ---- ---- 10 A10Q --- 10 A10R --- 20 --- A10Q 20 --- A10R 30 A10Q --- 30 A10R --- 30 --- A10Q 30 --- A10R 40 A10Q --- 40 --- A10R 50 A10Q --- 11 rows selected
So I need lines of the sample of data where COL1 = 10,20,30 and 40. 50 must be returned as it has only A10Q and not A10R.
I just need COL1 values.
I wrote the query below, but wanted to know if there is a better way to write this
Kind regardsselect * from table1 where col1 in (select col1 from table1 where (col2 = 'A10Q' or col3 = 'A10Q')) and (col2 = 'A10R' or col3 = 'A10R'); COL1 COL2 COL3 ---------------------- ---- ---- 10 A10R 20 A10R 30 A10R 30 A10R 40 A10R
VikramAssuming that the values cannot be duplicated for any group of individuals col1, something like that maybe...
select col1 from table1 where 'A10Q' in coalesce(col2, col3) or 'A10R' in coalesce(col2, col3) group by col1 having count(*) = 2
(not tested as you did not provide the data in a usable format)
-
Hi team,
I have the following query where I need to find the max value
[code]
with t as)
Select 'L1' R_nm, R_Data 'Data', 'Obj' R_Obj, r_prec 'Wd', '2' double val
Union of all the
Select 'L1', 'Data', 'Obj', 'No', '4' double
Union of all the
Select 'L2', 'Data', 'Obj', 'No', '4' double)
Select t.*, max (val) on rk (partition r_nm, r_data, r_obj) of t
[/ code]
My results should be
[code]
r_nm r_data r_obj r_prec rk val
L1 Data Obj 1 2 Wd
L1 data Obj 4 No.2
L2 Data Yes 1 1 Obj
[/ code]
Thank you
Hello
It seems that you are not interested in the MAX at all. Looks like you want to classify the lines, such as one that has the lowest value is assigned the number 1, the 2nd line with the lowest values gets 2,... and line with him gets N-th lowest value N. If is not serious if the MAX is 4, 2 or 420.
Here's a way to do it:
SELECT T.*
, RANK () OVER (PARTITION BY r_nm, r_obj)
ORDER BY val
) AS rk
T
ORDER BY r_nm, r_obj
val
;
Depending on how you want to deal with links, you can use ROW_NUMBER or DENSE_RANK instead of RANK.
-
Select the distinct value of a column in the collection in bulk.
Hi all
Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.
Collection has followiing values inside.
I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.Col(c).articleid, Col(c).userkey, Col(c).origin, Col(c).addnlorigindata, Col(c).avdest, Col(c).dispfmt, Col(c).sourcecode, Col(c).success_ind, Col(c).error_code, Col(c).entry_createddate, Col(c).createdby, Col(c).filenumber, Col(c).linenumber, Col(c).acctnum, Col(c).assetkey, Col(c).autocompletedterm, Col(c).accessionnumber, Col(c).requestdatetime, Col(c).requestorip, Col(c).articleordinal, Col(c).userinitiatedind, Col(c).captchastatus
Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.
Thanks n regards
Nana Akkivalli.The collection must be inserted before you can use this topic.
In the Begin block, you have to collect a loose and insert inside: something like
SELECT * BULK COLLECT INTO l_array FROM ALL_USER ...CONDITIONS...
-
Replace repeating lines with white and don't show the distinct values
Hi all
I have a SQL query that looks like this:
SELECT Item_id, item_details, category, group INC.
OF my_items
WHERE THE...
The results are as follows:
Item_id item_details category group
001 keyboard PC - 1 Grp1
001 keyboard PC - 2 Grp1
003 monitor PC - 1 Grp 1
003 monitor PC - 2 Grp 2
What I really want, it's like to have repeated as a draft values and keep only the distinct values. I want the output to be like this:
Item_id item_details category group
001 keyboard PC - 1 Grp1
PC-2
003 monitor PC - 1 Grp 1
PC - 2 Grp 2
Is there a way we can do that? Help, pleaseHere's a way using the Lag as mentioned by Tubby...
SQL> ed Wrote file afiedt.buf 1 with t as (select '001' as item_id, 'keyboard' as item_details, 'PC-1' as category, 'Grp1' as grp from dual union all 2 select '001', 'keyboard', 'PC-2', 'Grp1' from dual union all 3 select '003', 'monitor', 'PC-1', 'Grp1' from dual union all 4 select '003', 'monitor', 'PC-2', 'Grp2' from dual) 5 -- end of test data 6 select decode(item_id, lag(item_id) over (partition by item_id order by category, grp), null, item_id) as item_id 7 ,decode(item_details, lag(item_details) over (partition by item_id order by category, grp), null, item_details) as item_details 8 ,decode(category, lag(category) over (partition by item_id order by category, grp), null, category) as category 9 ,decode(grp, lag(grp) over (partition by item_id order by category, grp), null, grp) as grp 10 from t 11* order by t.item_id, t.category, t.grp SQL> / ITE ITEM_DET CATE GRP --- -------- ---- ---- 001 keyboard PC-1 Grp1 PC-2 003 monitor PC-1 Grp1 PC-2 Grp2 SQL>
-
Find the average value of a buffer
Hello
In my VI Panel, I have a digital control, a button and a digital display.
When the user, enter a number in numerical order and press the button, the digital display should show the average value of all the past 5 values entered in the digital control, for example:
1st entry: 10-online average = 10 (as sum = 10)
2nd type: 0-online average = 5 (as sum = 10 + 0 = 10)
3rd enter: 5-online average = 5 (you get the idea...)
4 enter: 1-average online = 4
5 enter: 14-online medium = 6
6 enter: 2-online average = 4.4 (sum = 0 + 5 + 1 + 14 + 2 = 22, because the 1st value is thrown)
How to write this VI?
Thank you!!
You can also use arrays to hold the data in a registry change and find the average value of the last five items.
Good luck
-
Find the minimum value of the table in time...
Firstly that it is not "find the min value in the table.
It is:
I have a table that changes its values at each iteration, and I want to compare the new values with previous values and make a new array with the minimum values...
In C++, it would be like this:
int main() {}
int array [8];
int min [8];
int i;
for (i = 0; i<>
min [i] = 1000000; Initialize minimum table with a high value
}
{while (1)}
Array = update_array ();
for (i = 0; i<>
If (array [i]<>
min [i] = array [i];
}
}
do things...
}
return 0;
}
IM new to labview and it always confuses me a lot...
Thanks in advance.
Using the function Max & Min regular (not table Max & min as you know) with tables and a good will of employment registry change. Max Min &, as most of the digital functions, is polymorphic and works witt tables as well as scalars.
Lynn
-
Hello
SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate.
Please help on this script and let me know if you need more details.
---
You use a SELECT statement. Let me know if you need more details.
-
What is the query to find the name of all applications for all EBS R12.1.3 modules?
With regard to:
Mr. Shahzad Saleem
Try:
SELECT * FROM fnd_concurrent_programs_vl;
-
Query to find the Pages and the list of permissions associated with a particular role in PS
I want a query to find the Pages and the list of permissions associated with specific roles in PS.
For example, if we see the role of manager accounts payable, it conatins Pages and the list of permissions.
But, to get everything in EXCEL sheet by Manuel priocess's BIG job. So, can someone give me the query.
Please try under queries
The roles assigned to the list of Perm:
SELECT B.ROLENAME
OF PSCLASSDEFN A, PSROLECLASS B
WHERE (A.CLASSID = B.CLASSID
AND A.CLASSID =: 1).
List of Perm pages can access:
SELECT B.MENUNAME, B.BARNAME, B.BARITEMNAME, B.PNLITEMNAME, C.PAGEACCESSDESCR, B.DISPLAYONLY
OF PSCLASSDEFN A, PSAUTHITEM B, PSPGEACCESSDESC C
WHERE (A.CLASSID = B.CLASSID
AND A.CLASSID =: 1
AND B.BARITEMNAME > ' '
AND B.AUTHORIZEDACTIONS = C.AUTHORIZEDACTIONS)
-
PL/SQL loop to find the minimum value
I want to find the minimum value from a table using the pl/sql loop
I have data format below.
1 ABC 2
1 ABC 20
1 ABC 500
1 ABC 2000
XYZ 2 250
JKL 3 300
MNP 3 350
3 KLM 400
I wrote the code below. His does not work. Please suggest.
Set serveroutput on
declare
x number: = 3;
y VARCHAR2 (3): = 'ABC ';
fmin number: = 0;
number of Fmax: = 0;
Start
for rec in (select sal from test
where id = name and x = y) loop
If rec.sal > fmin then
fmin: = rec.sal;
on the other
FMAX: = rec.sal;
fmin: = fmax.
end if;
end loop;
dbms_output.put_line (Fmax);
end;
/I want to output 2 on top of code.
Thanks in advance
Why PL/SQL? SELECT MIN (SAL) OF TEST will be more rapid and much less coding. In any case:
declare
number of v_min_sal;
Start
for v_rec in a loop (select sal from emp)
If nvl (v_min_sal, v_rec.sal + 1) > v_rec.sal
then
v_min_sal: = v_rec.sal;
end if;
end loop;
dbms_output.put_line (' lowest salaray is "' |") v_min_sal | '"');
end;
/
The lowest Salaray is "800".
PL/SQL procedure successfully completed.
SQL >
SY.
-
query to find the dependent task, attached to the task on a response in OIM 11 g
can someone help me to do a sql query to find the dependent task, attached to the task on a response in OIM 11 g
Published by: user13331347 on Sep 3, 2012 14:09Use under query to find the dependent task in OIM 11 g: -.
Select pkg.pkg_name, mil.mil_name, rsc.rsc_data, rsc.sta_key, sta.sta_status, sta.sta_bucket, mil2.mil_name
pkg pkg, tos tos, mil mil, mil mil2, rsc rsc, sta sta, rgm the rgm
where pkg.pkg_key = tos.pkg_key
and tos.tos_key = mil.tos_key
and mil.mil_key = rsc.mil_key
and rsc.sta_key = sta.sta_key
and rgm.rsc_key = rsc.rsc_key
and rgm.mil_key = mil2.mil_key
order of pkg.pkg_name, mil.mil_name, rsc.rsc_data, sta.sta_status, mil2.mil_name -
Query to find the coordinates of employee salary
Hello
Could someone help write the query to find the salary of the employee details.
Thanks in advance.This should help you get started:
SELECT papf.full_name
papf.email_address
ppp.proposed_salary_n salary
OF per_pay_proposals ppp
per_all_assignments_f ADP
per_all_people_f women's wear
WHERE ppp.assignment_id = paaf.assignment_id
AND paaf.assignment_type = 'E '.
AND paaf.primary_flag = 'Y '.
AND paaf.person_id = papf.person_id
AND nvl (papf.current_employee_flag, 'n') = 'Y '.
AND trunc (sysdate) BETWEEN
PPP.change_date AND ppp.date_to
AND trunc (sysdate) BETWEEN
PAAF.effective_start_date AND paaf.effective_end_date
AND trunc (sysdate) BETWEEN
PAPF.effective_start_date AND papf.effective_end_date; -
How to find the ASCII value of the TAB?
Hi friends,
I'm trying to find the ASCII value of the TAB character using ASCII standard as:
SELECT ASCII ('< TAB >') FROM DUAL;
I'm running the command above in SQL * more.
Is not treated as TAB.
It is considered space and give the ASCII value of the space - 32.
Please let me know how?
Version of Database - 9i
Concerning
Anthony Alix.Its only editor that gives you the problem; Try it on TOAD or sql developer, it works perfectly.
Is there a particular reason you want in sql * more?
-
SQL - find the minimum value for each separate record...
Hi all
I have a table like this in SQL Server
Date of sale of product
A date
A date
A date
B date of
B date of
C date
C date
C date
I would like to write a query to find the minimum date (i.e. the date
the first sale) for each product
Thus, the expected results would be
Date of sale of product
A date min
B date of min
C date of min
How can I do this using SQL Server?
any help is greatly appreciated!
Thank you!
Product SELECTION, MIN (sale_date)
From your_table
GROUP BY productEtienne
Maybe you are looking for
-
Install Flash is always in need of plugin
Have Firefox Beta for Android so I can play video through my Roku. A film site gave me a «necessary plugin...» "message so I installed Adobe flash recommended for my device. Flash downloaded and said it was installed OK, but when I try to open the Fl
-
Issue of synchronization with itunes and apple music
Hello world I'm from the India. & new to the IOS from android platform, I just bought a brand new 'Apple Ipod touch 6th Gen'. I would like to know one thing... I synced my music downloaded to my PC folder to itunes by the option 'add files/folders '.
-
Windows server 2012r2 essentials for datacenter
As the title, is Hi possible to convert the essentials of windows server 2012 r2 Datacenter? I received a key from one of my friends and I want to activate it, but I don't know if this is possible. Thanks for help/read!
-
Relocation of Mcaffe antivirus
After much troubleshooting, I got a new processor and hard drive installed on my Inspiron one desktop. Unfortunately, he returned to the factory specifications, but it seems that a lot of the delivered software pre-installed on my PC is gone. Most co
-
JDE for the functionality of the camera?
I just want to know what JDE would be preferable for the development of applications with camera, maps, gps?