How to select only rows with multiple records below?
Dear all,My Table looks at below:
Table structure:
CREATE TABLE T_20 (CONTROL NUMBER(10) NOT NULL,
PO NUMBER(10) NOT NULL,
AMENDNO NUMBER(3) NOT NULL,
FACTOR VARCHAR2(3) NOT NULL,
COMMENT_X VARCHAR2(40),
FLAG VARCHAR2(1))
SQL> alter table t_20 add constraint t_20_pk primary key (control, po, amendno, factor);
INSERT orders:SQL> INSERT INTO T_20 VALUES(101,1000,01,'MSC','NO COMMENT','Y')
2 /
1 row created.
SQL> INSERT INTO T_20 VALUES(101,1000,02,'MSC','NO COMMENT','Y')
2 /
1 row created.
SQL> INSERT INTO T_20 VALUES(101,1001,00,'NDP','NO COMMENT','Y')
2 /
1 row created.
SQL> INSERT INTO T_20 VALUES(101,1001,01,'NDP','NO COMMENT','Y')
2 /
1 row created.
SQL> INSERT INTO T_20 VALUES(102,1002,00,'ABC','NO COMMENT','Y')
2 /
1 row created.
out put:SQL> SELECT * FROM T_20
2 /
CONTROL PO AMENDNO FAC COMMENT_X F
---------- ---------- ---------- --- ---------------------------------------- -
101 1000 1 MSC NO COMMENT Y
101 1000 2 MSC NO COMMENT Y
101 1001 0 NDP NO COMMENT Y
101 1001 1 NDP NO COMMENT Y
102 1002 0 ABC NO COMMENT Y
Now, I want to select only the control number that have several acht.In above example only control 101 with several PO 2 PO with 1000 and 1001
So I need to select only this 101 related lines...
for 102 having in. sinple folders then it will have to be removed... because I have millions of records in the primary table...
someone you suggest query... Thank you..
Thanks in advance
Prasanth
Try this
select *
from (
select t.*, count(distinct po) over(partition by control) cnt
from t_20
)
where cnt > 1
Tags: Database
Similar Questions
-
How to configure a VM with multiple network cards to see Agent?
How to configure a VM with multiple network cards to see Agent?
We can archive this requirement by configuring the subnet used view Agent.
The subnet determines which view address of Network Agent provides the server instance to connect to view for the client protocol connections. The view on VM officer has more than one NIC
Follow the procedure below:
on a display Agent installed VM,
* Recording of VM session.
* RUN--> type regedit or type regedit.exe at the command prompt
* Create a registry entry to configure the subnet.
For example: is HKLM\Software\VMware, Inc. \VMware VDM\Node Manager\subnet = n.n.n.n/m type - REG_SZ.
In this example, n.n.n.n is the TCP/IP subnet, and m is the number of bits in the subnet mask.
-
Select the rows with values max.
SELECT MOFFER.DELIVERYPURCHASE, MOFFER.OFFERSTART, MOFFER.OFFEREND, MOFFER.RANKING, MMTDEMANDBID.BALANCEGROUPPK FROM EMTMOFFER MOFFER INNER JOIN MMTDEMANDBID ON MOFFER.OFFERID = MMTDEMANDBID.MMTDEMANDBIDPK WHERE MOFFER.DELIVERYPURCHASE = 'P' AND MOFFER.OFFERSTART >= '2012-01-18T00:00:00' AND MOFFER.OFFEREND <= '2012-01-19T00:00:00' AND MMTDEMANDBID.BALANCEGROUPPK = '10393'
Help, please. How to select lines with RANKING max, OFFERSTART and OFFEREND if the same.DELIVERYPURCHASE OFFERSTART OFFEREND RANKING BALANCEGROUPPK ---------------- ------------------- ------------------- ---------------------- ---------------------- *P 2012-01-18T23:00:00 2012-01-19T00:00:00 2 10393* P 2012-01-18T23:00:00 2012-01-19T00:00:00 3 10393 P 2012-01-18T00:00:00 2012-01-18T01:00:00 2 10393 P 2012-01-18T01:00:00 2012-01-18T02:00:00 2 10393 *P 2012-01-18T02:00:00 2012-01-18T03:00:00 1 10393* P 2012-01-18T02:00:00 2012-01-18T03:00:00 2 10393 P 2012-01-18T03:00:00 2012-01-18T04:00:00 2 10393 P 2012-01-18T04:00:00 2012-01-18T05:00:00 2 10393 *P 2012-01-18T05:00:00 2012-01-18T06:00:00 1 10393* P 2012-01-18T05:00:00 2012-01-18T06:00:00 2 10393 P 2012-01-18T06:00:00 2012-01-18T07:00:00 2 10393 P 2012-01-18T07:00:00 2012-01-18T08:00:00 2 10393 P 2012-01-18T08:00:00 2012-01-18T09:00:00 2 10393 P 2012-01-18T09:00:00 2012-01-18T10:00:00 2 10393 P 2012-01-18T10:00:00 2012-01-18T11:00:00 2 10393 P 2012-01-18T11:00:00 2012-01-18T12:00:00 2 10393 P 2012-01-18T12:00:00 2012-01-18T13:00:00 1 10393 P 2012-01-18T13:00:00 2012-01-18T14:00:00 1 10393 P 2012-01-18T14:00:00 2012-01-18T15:00:00 1 10393 P 2012-01-18T15:00:00 2012-01-18T16:00:00 2 10393 P 2012-01-18T16:00:00 2012-01-18T17:00:00 2 10393 P 2012-01-18T17:00:00 2012-01-18T18:00:00 2 10393 P 2012-01-18T18:00:00 2012-01-18T19:00:00 2 10393 P 2012-01-18T19:00:00 2012-01-18T20:00:00 2 10393 P 2012-01-18T20:00:00 2012-01-18T21:00:00 2 10393 P 2012-01-18T21:00:00 2012-01-18T22:00:00 2 10393 P 2012-01-18T22:00:00 2012-01-18T23:00:00 2 10393 27 rows selected
Get 24 ranks. One for every hour.SELECT MOFFER. DELIVERYPURCHASE,
MOFFER. OFFERSTART,
MOFFER. OFFEREND,
Max (MOFFER. (Rank CLASSIFICATION),
MMTDEMANDBID. BALANCEGROUPPK
OF EMTMOFFER MOFFER
INNER JOIN MMTDEMANDBID ON MOFFER. OFFERID = MMTDEMANDBID. MMTDEMANDBIDPK
WHERE MOFFER. DELIVERYPURCHASE = 'P '.
AND MOFFER. OFFERSTART > = ' 2012 - 01-18T 00: 00:00'
AND MOFFER. OFFEREND<=>=>
AND MMTDEMANDBID. BALANCEGROUPPK = '10393'
Group of MMTDEMANDBID. BALANCEGROUPPK, deliverypurchase, offerstart, offerend -
How to select only the URLS in the same page
I'm used to be able to select only the URL with right click of the entire page. After reinstalling Firefox, I can't use this feature more. Please let me know what kind of add-on, I need to have. Thank you
I looked in the Wayback Machine for an older version of this page. He said:
Multi links allows you to open, copy or favorite of several links at the same time rather than having to do them all individually.
To open, links copy or bookmark, you simply right-click and do to drag a rectangle around the links to the desire to act. When you release the right mouse button, you will open/copy/bookmark these links.Note: The Wayback Machine does not cache downloads real extension due to the limitations of robots.txt on the site of modules.
One of these current extensions could be partial replacement:
I have not tried any of them myself.
-
How to select the paths with the same line width
I would like to know how to select all the paths within a document whose line width are equal at 0.361 points
I'd appreciate any help.
Here you go
#target illustrator // script.name = selectPathsThisSize.jsx; // script.description = selects pathItems that have the same supplied stroke width; limited to 3 decimals; // script.required = a document with at least one path item; // script.parent = CarlosCanto // 6/5/11; // script.elegant = false; var idoc = app.activeDocument; var strokewidth = prompt ("Enter Stroke Width in points of paths to be selected", 0.361, "Select Paths this size:___"); for (i=0 ; i< idoc.pathItems.length; i++) { var ipath = idoc.pathItems[i]; if ( (ipath.strokeWidth).toFixed(3) == Number(strokewidth).toFixed(3)) { ipath.selected = true; } } app.redraw();
-
How to select only the objects in a marquee?
I am a new user of Illustrator CS5, switching from Freehand. I'm trying to find out if there is a way to select only the objects in a marquee? In AutoCAD, you can make a selection on the left window to the right and only those objects entirely in the window are selected. If you the window right on the left all the objects that are "crossed" or affected by the window are selected. Is there a similar technique in Illustrator?
Currently, I have to select the objects, and then go back and hold the SHIFT key to deselect the object I don't want, or lock layers to prevent additional items get selected.
NO.
-
This is how a SELECT query fails with ORA-1555 occur?
11 GR 2/RHEL 6.2
I would like to know exactly how a SQL fails with error ORA-1555.
Please take a look at the following simple example.
INVENTORY_DETAIL is a table that stores information about items in a store.
For this DB UNDO_RETENTION is set to 3 600 (1 hour) and TUNED_UNDO_RETENTION Meanwhile 5400 (1.5 hours)
At 15:00, there's 12 Logitek involved in inventory.
ITEM_ID NOM_ELEMENT STOCK_LEFT
--------- -------------------- ----------
8432 LOGITEK 12 SPEAKER
At 15:00 Session1, starts a SELECT large with several tables joins query. Something like
Select id.item_id, id.item_name, su.supplier_price, su.supplier_code
Su.batch_code...
of INVENTORY_DETAIL id join in-house suppliers knew on (id.supplier_id = su.supplier_id)
...
..
03:02, Session1 reads the block that stores the line with item_id = 8432 and learns that he has 12 Logitek left speakers.
15:10, Session2 delivers the next UPDATE and he agrees immediately.
Update inventory_detail set stock_left = 7 where item_id = 8432;
commit;
The UNDO data for Session2 transaction are stored in the measure of cancellation remaining, and the UNDO data gets debusquees at 04:40 when the TUNED_UNDO_RETENTION of 1.5 hours is crossed at 16:40.
Because of the bad of e/s, query SELECT of Session1 manages to retrieve all the records only from 17:00.
But session1 notice this line with item_id = 8432 changed. Now, there's only 7 Logitek speakers which is inconsistent with what he learned at 15:02 (who was then at 12). Because of this incompatibility SO not able to recover data UNDO on this gap, ORA-1555 is thrown. My assumptions are good?
3:10PM 4:10PM 4:40PM 5:00PM
|===================================|-------------------------------|-----------------------------|
UNDO_RETENTION = 1 HR retention Undo Tuned = 1.5 h finishes of request for enforcement
Martin, you asked, "are the correct on the circumstances that led to ORA-1555 my explanations? The answer is no. Oracle does not notice at the end of the query that changed a line he read. Instead, each read line is at the same point in time. When Oracle sees that a row has changed Oracle reads the UNDO segments to find the version of the data corresponding to the query start time. If these data cannot be found the ORA-01555 error is raised.
- -
HTH - Mark D Powell.
-
How to read only the most recent records in PL/SQL
Oracle version: 11.2
I have a table in ORACLE called RATES and it is EFFECTIVE_DATE, RATE_NAME, RATE_AMOUNT
RATE
------------
1 RATE_ONE 01/01/2000 0.10
2 RATE_ONE 01/05/2005 0.15
RATE_ONE 12/01/2010 3, 0.20
RATE_TWO 4 10/15/2009 0.33
5 RATE_THREE 07/09/2011 0.05
6 RATE_THREE 31/12/2011 0.06
A rate can be there several times, but the most recent rate is the rate of the asset. I need to query this table and want only to bring the currently active lines:
DOCUMENTS 3, 4 and 6
How can I do this in the most elegant way?
I can say:
SELECT RATE WHERE trunc (sysdate) between EFFECTIVE_DATE and trunc (sysdate);
(it will not work. I don't know how to do this without a date column exp and then I could tell
SELECT RATE WHERE trunc (sysdate) between EFFECTIVE_DATE and end_date
The problem is that I can't add this column at this time, so need to find a way to do it by programming
Published by: userLynx on February 1, 2012 08:56Hello
Here's one way:
WITH got_r_num AS ( SELECT rate.* -- or list columns you want , RANK () OVER ( PARTITION BY rate_name ORDER BY effective_date DESC ) AS r_num FROM rate -- WHERE ... -- If you need any filtering, put it here ) SELECT * -- Or list all columns except r_num FROM got_r_num WHERE r_num = 1 ;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
If the combination (rate_name, effective_date) is not unique, this includes all rows that have the last effective_date for this rate_name. If you want exactly one line per rate_name when there is a tie, then add the columns of tiebreaker to analytical or use ROW_NUMBER instead of RANK ORDER BY clause.
-
How to select only the part by using the sql query
Hello
I have the task to retrieve only the integral of the input text by using the sql query.
The entry is as follows
Entry for the price setting
$12.5 (FYI without space)
$ 12.5 (FYI single space)
$ 12.5 (double space FYI)
$12.5 (FYI multiple space)
$12.5 (FYI multiple space)
Output expected of 12.5
The price is the type varchar2 column in the store_price table.
Please let me know how to achieve this.
Thanks in advance.
If this is always the case that you get a $ followed by a number of places, you can use something like:
Select to_number (ltrim ('$ 12.5',' $')) DOUBLE
or
SELECT ltrim ('$ 12.5',' $') OF double
but take care of your nls_numeric_character settings if they are defined so that, for example, a comma is the decimal separator, you will have a problem.
HTH
-
Clone of the drive selected only--ignore the independent record
I have a virtual machine with two drives. the first disk contains the operating system and is a standard virtual disk. The second disc is independent - persistent. I want hot Clone ONLY the OS disk and ignore the independent drive. I have a Powershell script that will clone a virtual machine, but I need to know how to jump the independent drive.
It seems that it is possible to copy a vmdk selected a virtual computer on the ground, but I need to be able to make a clone of hot. Is this possible via Powershell?
Here is the code for the loop. Replace # DO comment on the line and everything up to the # clean comment by the following
## DO IT -- NOTE that CopyVirtualDisk_Task is 'experimental' as of vSphere 4.0 GA $taskMoRef = $vdiskMgr.CopyVirtualDisk_Task($sourceDS, $sourceDC, $destDS, $destDC, $destSpec, $force) $task = Get-View $taskMoRef $info = get-task | where {$_.id -like "*-"+$task.info.key} while ($task.Info.State -eq "running" -or $task.Info.State -eq "queued") { sleep 10 $info = get-task | where {$_.id -like "*-"+$task.info.key} $task = Get-View $taskMoRef Write-Host "Task" $task.info.state "," $info.percentcomplete "% complete." } } }
-
How to share the library with multiple users?
I have a Mac Pro 2008. I have four internal hard drives. One of them is an SSD that is my boot drive. I have another internal drive that houses my music and movies (2 TB).
I have four different connections - mine (admin), my wife, my son, my daughter.
How can I share music on (2 TB) library with other users? I read to the music folder (shared) - however since the 2 TB is not a boot disc, there is no shared folder.
You try to share an iTunes library, or the drive contains just music files.
Other users can see the drive, or simply don't have access to the records.
-
How to select several values with a select statement with other columns
Hi all
I have a small request related to the selection of values in a table.
create table employees (eid, ename varchar2 (20));
insert into employee values (1, 'Nik');
insert into employee values (2, "Prashant");
commit;
Now, I have a small list of say A, b, C, I want to choose this list with all the lines aswith test1 as)
Check the eid, ename for employee
)
Select eid, ename, 'A' col1 in test1
UNION ALL
Select eid, ename, 'B' col1 in test1
UNION ALL
Select eid, ename, 'C' col1 in test1
but the problem with that is that in production my employee table has millions of records and it scans the employee three times table (or the number of constant values)
Is there another way to do this.
Thank you
Nik
Here is an approach with the scanning of a single table test1
Select t.eid, t.ename, c.col1
t test1
Cross join (select 'A' col1 of union double all the)
Select 'B' of all the double union
Select the double ' C') c
-
How to find end rowa with 1 digital duplicates in a table
Hello world
I have a customer requirement to get the records in a table that are end with the digital 1.
Few of the user accounts, added with a '1' at the end of their normal user IDs. Everything by making some process in-house, the system has created a new account with the '1' appended to the end.
So I need a query to correctly identify these users.
Here is the sample records:
PK1 userid name lastname email
1 AAA Jack smith j.smith@a
2 AAA1 Jack smith j.smith@a
3 BBB Scott S s.scott@a
4 BBB1 Scott S s.scott@a
Note: name and email id and name are the same
Of the above, I need to get the records of AAA1 and BBB1.
My output should be like below
AAA1 2 Jack
4 Scott BBB1
Please help me on this.
Thanks in advance.
Hello
One way to do that is to add a condition EXISTS to the above:
SELECT pk1, userid, name
From your_table m
WHERE SUBSTR (userid,-1) = "1" - or userid WHERE AS '%1 '.
AND THERE ARE)
SELECT 1
From your_table
WHERE userid | '1' = m.userid
AND name = $m.name
AND lastname = m.lastname
AND email = m.email
)
;
-
Build the query in PLSQL to return well formed XML with multiple records
Hello
It's very urgent. I am creating a PLSQL query who must retrieve all records in the table of "tbl_Emp" oracle database in a well-formed xml format. The format is given below
* < employees xmlns = "http://App.Schemas.Employees" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" > *.
* < employee > *.
* < name > < / name >. *
* < Last_Name > < / Last_Name > *.
* < / employee > *.
* < employee > *.
* < name > < / name >. *
* < Last_Name > < / Last_Name > *.
* < / employee > *.
*...*
* < / employees > *.
To retrieve data in above format, I tried to create a query for a long time as below
SELECT XMLElement ('employees',
XMLAttributes ('http://App.Schemas.Employees' AS 'xmlns',
(* "http://www.w3.org/2001/XMLSchema-instance" AS "xmlns: xsi"), *.
XMLElement ("employee", XMLForest (First_Name, Last_Name)))
AS 'RESULT '.
OF tbl_Emp;
But it does not give me the desired output. It creates the < Employees > tag with each individual record which I didn't need. I need tag < Employees > the root tag and the tag < employee > repeat and wrap each individual record. Please help me in that it's very urgent. Thank you.Hello
Remember that nothing is 'urgent' here, and repeating it will probably produce the opposite effect.
If you need a quick answer, provide all necessary details, in the first place:
-version of db
-test with sample data and DDL casesThat being said, it's easy, it takes group using XMLAgg:
SELECT XMLElement("Employees" , XMLAttributes( 'http://App.Schemas.Employees' AS "xmlns" , 'http://www.w3.org/2001/XMLSchema-instance' AS "xmlns:xsi" ) , XMLAgg( XMLElement("Employee" , XMLForest( e.first_name as "First_Name" , e.last_name as "Last_Name" ) ) ) ) AS "RESULT" FROM hr.employees e ;
-
How to show only layers with layer filtering layers?
Is there a way I can have showing only the layers, files, colors, text, and al. I've worked with in a composition of specific layers in the layer panel? I thought I could achieve with layer filtering, but is the closest with "Selected", the problem is that I lose my folder structure I.
Thank you in advanced for your help.
Attribute > Visible (edit: with this layer selected either Comp)?
Maybe you are looking for
-
How to fix - cartridge missing or not detected
have a photosmart c4280 all-in-one, CC210A. to get the message that the cartridges are not detected. Both are loaded correctly. I suspect that a sensor is crapped out. over time, maybe ink excessive spray? How to fix?
-
Receive windows essential to work on xp64
Is there a compatibility mode for wlsetu. or anyway to run windows live essentials on xp64
-
How can I see a history of connection to my PC with Windows XP?
I'm just checking the history of connection to my laptop using Windows PC - only the administrator and a user ID and want to be able to see the history of connection for both (date/time of connection, etc.). Any help?
-
OK, I'm almost certain that it is a hardware problem; probably in the hard drive (because that's what I read form similar problems online). I have a Dell XPS m1330 laptop computer, 2 GB of Ram, Vista Home Premium, 2.2 GHz processor, Nvidia G8400 MS w
-
Location of the CRG App Sqlite and explore
Hi allI use Jdeveloper 12.1.3 with PSM 2.1 to build an application that uses Oracle A-team persistence accelerator to implement offline functionality.I'm exploring the database of lite sql that is generated once the data is stored inside.I used the A