How to select rows in this way ?????
Hi All,
How to select tables from 2 table say client and vendor. Both have id, name. Now I want data of two tables using union but the data of one table come after another.
select id,name from vsg.client union select id,name from vsg.vendor
Eg.
Vendor Client
ID Name ID Name
1 ab 12 xyz
2 cd 13 wyx
3 ef 14 pqr
Now output should come like this
ID Name
1 ab (First rows from Vendor)
2 cd
3 ef
12 xyz (second rows from Client)
13 wyx
14 pqr
Thanks for your reply in advance......
NO this one is not workingWhy not? Are you using some ancient version of Oracle?
SQL> create table vendor
2 as
3 select 'v1' id, 'a' name from dual union all
4 select 'v3', 'c' from dual union all
5 select 'v2', 'b' from dual
6 /
Tabel is aangemaakt.
SQL> create table client
2 as
3 select 'c1' id, 'd' name from dual union all
4 select 'c3', 'f' from dual union all
5 select 'c2', 'e' from dual union all
6 select 'c4', 'g' from dual
7 /
Tabel is aangemaakt.
SQL> select id
2 , name
3 from ( select id
4 , name
5 , 1 x
6 from vendor
7 union all
8 select id
9 , name
10 , 2
11 from client
12 )
13 order by x
14 , id
15 /
ID N
v1 a
v2 b
v3 c
c1 d
c2 e
c3 f
c4 g
7 rijen zijn geselecteerd.Regards,
Rob.
Similar Messages
-
Ok so here's what has happened. I got on the Mac to open IPhoto. It opened, but no files PERIOD! No albums, events, photos, faces. They were all empty. I had TONS of albums and photos. I have no clue how long it's been this way, probably a couple of weeks since I've been on it. Ac couple of things come to mind that might have caused or had something to do with...IPhone 4 had to be restored and a back-up and upgrade occurred. Also, I deleted files off my camera while connected. Not sure the culprit, but VERY UPSET! I have never set up Time Machine and have no other back up. I downloaded and purchased File Salvage but I have to get an external hard drive before it will do it. I put the application install CD in last night thinking that if I reinstalled it would help but then I got scared and shut Mac down half way through. I couldn't even find the file IPhoto Library. When I open IPhoto it say IPhoto 9 but when I "get more info" it says IPhoto 8.1.2 or something like that. Please HELP!!
Try an All Images Search:
In the Finder:
Command - f
Kind: Images
Size: Greater than 300kb (This is to avoid all the thumbnails, icons and so on.)
Set it to search the Mac.
As to why? The most likely answer is user error, I'm afriad. It does point up the importantce of always having a back up.
Regards
TD -
How to select rows in the inner JTable rendered in an outer JTable cell
I have wrriten the following code for creating cell specific renderer - JTable rendered in a cell of a JTable.
table=new JTable(data,columnNames)
public TableCellRenderer getCellRenderer(int row, int column)
if ((row == 0) && (column == 0))
return new ColorRenderer();
else if((row == 1) && (column == 0))
return new ColorRenderer1();
else
return super.getCellRenderer(row, column);
ColorRenderer and ColorRenderer1 are two inner classes, which implement TableCellRenderer to draw inner JTable on the outer JTable cell, having 2 rows and 1 column each.
Now what is happening the above code keeps executing continously, that is the classes are being initialised continously, inner JTables are rendered (drawn) continously, and this makes the application slow after some time. It throws java.lang.OutOfMemoryException.
WHY IS IT SO??? I can't understand where's the bug..
Any advice please???
Moreover i want selections in inner tables and not on outer table, how can this be possible.
I am working on this since a long time but have not yet found a way out...With your help i have overcome the problem of continous repeatition.
The major problem which I am facing is, in selecting rows in the inner rendered JTables.
I have added listener on outer JTable which select rows on the outer JTable, hence the complete inner JTable which being treated as a row, gets selected.
The thing is i need to select the rows of inner rendered JTables,not the outer JTable.
How to go about it??
I have even added listener to inner rendered JTables, but only first row of every table gets selected.
Please help....
Thanks in advance. -
How to select rows in adf faces table
Hi guys
im new to adf faces .I created a adf faces table with some data.My task is to select one row and if i click tht row, the data of tht row will be displayed in an input text fileds.How can i select a row in a adf faces table and give actions to rows...i read so many tutorials...none of them didnt give a correct idea....plz help me...
thanks in advance..
rajivYou're here in the Sun JSF forum, not in the Oracle JSF forum.
Try here: JDeveloper and ADF
If the ADF datatable is technically comparable with the RI datatable, check http://balusc.xs4all.nl/srv/dev-jep-dat.html to get some insights how to retrieve the selected row object. -
How to use classloader in this way? Is it possible?
I have one my own classlaod. So, I can do these: use the classloader to load the class, use the class's newInstance method to get instance object, then use reflection to invoke methods of the object.
I think this is the standard way.
However, it is not convenient. Is there a way that allows me to using the class that loaded by my own classload in "old way", i.e. just new to get object, and directly use it. For example, like this:
..Get classloader
class MyClass = loadClass("MyClass");
MyClass obj = new MyClass();
obj.someMethod();
If this way is possible, it is much better. In theory, it should have no problem. I think Java Web Start, etc are just doing similar like this. But, at this point, I do not know. Please share your thoughts.You have to distinguish between compile time, and run time features available to you.
MyClass x = new MyClass() ; is a language construct that is available at compile time.
Reflection is available at runtime.
If you want a mix of both, you may have to generate code. Depending on how you like it - you can either generate source and compile it, or generate byte code directly. But since you seem to be interested more in simplifying your code, due to the relative obscurity of reflective code, your best option would be to use a code generator.
So use your classloader to load the class, then generate and compile code to use it. (This may be even more complex, but this is how you would have to do it) -
How to select rows from database like 10 to 20 etc
Hi Experts,
I want to select rows from database like row number 10 to row number 20.How could it be done?HI,
First get the data into the INTERNAL TABLE from the FLAT FILE and read the internal table using the index.
ex: 1) Read table ITAB index 10.
2) Read table ITAB index 20.
or use as said by Srinivas Gurram, to get the range of records using where condition to the loop.
<REMOVED BY MODERATOR>
Edited by: Ravi Kumar on Jun 9, 2008 4:01 PM
Edited by: Alvaro Tejada Galindo on Jun 9, 2008 3:16 PM -
Hi all,
How to select distinct rows without using distinct,unique key word.
When ever i use distinct key word oracle database is hanging ..
regards
prakashHow to select distinct rows without using distinct,unique key word.
When ever i use distinct key word oracle database is hanging ..The database isn't 'hanging'. It just needs more time than you want to do what you asked it to do.
The standard counter-questions are:
- why do you need a distinct (or group by)?
- could it be that your datamodel needs some adjustments?
- how many rows are you expecting?
- how many rows are you selecting from?
- what does the query look like?
- what database version are you working with (the result of: select * from v$version; ) ?
There is no substitute for DISTINCT|UNIQUE (or GROUP BY), you should really think about why you need a DISTINCT in the first place, since it's killing the performance of the database in the first place, especially on (very) large sets.
Since you're actually having a performance problem, I suggest you read:
HOW TO: Post a SQL statement tuning request - template posting
and post all relevant details you've left out so far. -
How to select row automatically in matrix (exp:automatic select row no 2)?
Hi
example i fill matrix row no 1 - 3 in serial number selection form or else (from database data)
and i want to automatic select row no 2
and i really have a big problem to do this
oQuant = edit text
oColumn = column
oForm = form
here some of my code
====================================
formID = pVal.FormUID
Set oForm = SBO_Application.Forms(formID)
Set oMatrix3 = oForm.Items.Item("5").Specific
Set oColumn3(3) = oMatrix3.Columns.Item("19")
Set oQuant(5) = oColumn3(3).Cells.Item(2).Specific
=====================================
i tried
oMatrix3.SelectRow 2, True, False
but it didn't work , it's said that not user defined item
oQuant(5).Active = True
it works but that not the select what i want
pls some one help me
i really need it right away
ThanksHi chetan
Thank You for your reply and yes i didn't write selection mode for my matrix
but when i tried both of these code it still didn't work (for information i'm using visual basic 6, so it has a different syntax about .net and VB6 - exp: for .net oMatrix.selectrow(2,true,false) , for VB6 oMatrix.selectrow 2,true,false )
oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto
oMatrix.SelectRow 2, True, False
oMatrix.SelectionMode = ms_Auto
oMatrix.SelectRow 2, True, False
is there any presiquities for selection mode ?? because I always have <b>warning</b> on oMatrix.selectionmode
"<b>Item - the item is not user defined item</b>"
Edit : it works when i created a form and select row no 2, but it didn't work with serial number selection form which the form is already exist in SBO (serial number selection is the form after klik add button in good issue form)
Thanks -
How to get output in this way ?
actual data is this :
CRANE_ID CRANE_CASE SEQ desc
C01 NORM 1 desc1
C01 NORM 2 desc2
C01 NORM 3 desc3
C01 NORM 4 desc4
C01 XX1 1 desc5
C01 XX1 2 desc6
C02 NORM 1 desc7
C02 XX1 2 desc8
C03 NORM 1 desc9
C03 XX2 2 desc10
how to get data in this format :
crane_id case 1 2 3 4
C01 NORM desc1 desc2 desc3 desc4
C01 XX1 desc5 desc6
C02 NORM desc7
C02 XX1 desc8
C03 NORM desc9
C03 XX2 desc10
header should contain all sequence that is maximum.How to group my output w.r.t one column ?
you need to do your own homework assignments -
Add Column Delete in report, How to delete row using this delete Option
Hi Friends,
i have a report ,iwant to add an option DELETE in last column.When i click on DElete then respective id sholund be deleted.
My Table Is
CREATE TABLE "DUMY_FILE"
( "ID" NUMBER,
"NAME" VARCHAR2(500),
"FILE_OBJ_ID" NUMBER,
"MIME_TYPE" CLOB,
"DOC_SIZE" NUMBER,
"BLOB_CONTENT" BLOB,
"DESCRIPTION" VARCHAR2(500),
"UPLOAD_DATE" CHAR(25)
How can i do this.
Thanks
Edited by: 805629 on Nov 16, 2010 11:51 PMTrent,
Thanks for you suggestions. .. Let me explain my problem a little better ...
I have a report that lists fields associated with a report ... I have a delete icon which deletes a row and removes it from the underlying table ... however, I am trying to implement a Before header process which runs a pl/sql process that checks if the selected field is the last field in the report ... if so, I want a confirmation dialog to pop up ... if they click cancel .. then the deletion is aborted, else the field is deleted (which triggers other status changes).
Based on this logic if there is a way to implement this based on your suggestion I would appreciate it ...
Here is the process I was trying to use .... but the I have a few issues with this approach
declare
-- cursor to check if this is the last field
cursor fld_cnt is
select count(*) from prm_ptnr_rpt_fields
where report_uid = :P22_REPORT_UID;
num_flds number;
msg varchar2(300);
begin
open fld_cnt;
fetch fld_cnt into num_flds;
If num_flds > 1 then
delete from prm_ptnr_rpt_fields
where report_uid = :P22_REPORT_UID
and field_user_key = :P9_DELETED_FLD;
commit;
:P9_DELETED_FLD := NULL;
msg := :P9_FIELD_NAME || ' Field Excluded From Report' ;
apex_application.g_print_success_message := msg;
else
htp.p('<script type="text/javascript">');
htp.p('
var r=confirm("This is the last field included in this report .. \n Deleting it will Inactivate the report and remove it from schedule (if scheduled) ...\n Do you want to proceed?");
if (r==true)
{ delete from prm_ptnr_rpt_fields
where report_uid = :P22_REPORT_UID
and field_user_key = :P9_DELETED_FLD;
:P9_DELETED_FLD := NULL;
commit;
msg := :P9_FIELD_NAME || ' Field Excluded From Report' ;
update prm_ptnr_rpts
set report_status = 'INCOMPLETE',
active_report = 'N'
where report_uid = :P22_REPORT_UID;
msg := msg || ' and Report Status changed to INCOMPLETE';
apex_application.g_print_success_message := msg;
htp.p('}else {
alert("Delete Action Aborted");
htp.p('</script>');
End if;
Close fld_cnt;
end;
a) Even if I click cancel ... the field still gets deleted ...
b) :P9_DELETED_FLD is the id for the selected field ... I am setting it on the link attributes which places it on the URL ... I would rather user javascript (but not exactly sure how).
Thanks,
Gerald
Edited by: user5459177 on Feb 22, 2011 2:45 PM -
How to select rows or columns of tables without using the mouse?
2nd post ever! Yeah! \m/
In Excel, I can select entire rows or columns of data WITHIN TABLES--i.e., not selecting entire sheet rows or columns--by going to any cell on the perimeter of the table, holding down shift+ctrl, and clicking a direction arrow. So for example, if I have a table in columns D-G and rows 1-5, I can highlight row 4 by going to the first or last cell of that row, holding down the shift+ctrl, and hitting the appropriate direction arrow. You might think this is superfluous given that you can use the mouse to select cells. But that becomes cumbersome with large tables, and this method can be more efficient even with small tables.
Similarly, it's often useful to navigate tables, particularly large ones, by moving from any cell within the table to the end or beginning of that row or column by holding down ctrl and hitting the appropriate arrow key. In Excel, this ctrl+arrow key method also allows you to skip blank cells, which is another very useful navigational feature.
I tried numerous combos involving shift, ctrl, command, alt/option and the arrow keys. Haven't found a way to do any of this yet.
Anyone?Hi Josh,
Numbers is organized differently than Excel, and the navigation tools are different too. Many of us miss our particular favorites from spreadsheets past, but this is Numbers, not a clone. The biggest adjustment is to go from huge monolithic sheet-tables containing virtual sub-tables to a simple blank sheet with small tables, sometimes many per sheet. Navigating is no big deal in these small tables and neither is getting from one small table to another, using the Sheets pane.
Selecting a particular Table is as easy as clicking on the table's name in the Sheets pane. Selecting a particular row, or column, or ranges of rows or columns is done by clicking on the table's row and column labels, left side and top side once a cell is selected in the table.
Numbers is weak at handling large Tables and documents that are large overall. We know this and many of us still prefer it to the alternative when the tool fits the task.
Jerry -
How to select rows whose one column contains some specific characters ?
These is a table say T1 with a column say C1
Let the field C1's values be:
row 1)DE/SPT/A/FWD
row 2)G/SPT/DE/DE/SPT
row 3)R/FWD/SPT/A/FWD/FWD
row 4)A/A/DE/SPT/FWD
row 5)FWD/SPT/E/DE/A
How to get only those rows whose C1 column contains FWD in last ?We can solve this with the simple use of a wildcard:
select *
from t1
where c1 like '%FWD'
/Note that this query will execute a full table scan, because any index you may have on C1 will be ignored: indexes are organised on the leading characters.
cheers, APC -
How to select rows with duplicate column values
hi,
i have a table property_details which has these 2 columns customerno and propertyno a customer can have many properties and property number has to be unique. but somehow these property number has been duplicated at an earlier stage so i have for a customer with many properties the same property number
how i will select such records whose asset numbers are the same
for ex
customer no property no
a1300 1
a1300 1
a1300 1
a2330 10
a2330 10
a2330 10
kindly suggest me a solutionthis example might be of help.
SQL> select * from employees;
YEAR EM NAME PO
2001 02 Scott 91
2001 02 Scott 01
2001 02 Scott 07
2001 03 Tom 81
2001 03 Tom 84
2001 03 Tom 87
6 rows selected.
SQL> select year, empcode, name, position,
2 row_number() over (partition by year, empcode, name
3 order by year, empcode, name, position) as rn
4 from employees;
YEAR EM NAME PO RN
2001 02 Scott 01 1
2001 02 Scott 07 2
2001 02 Scott 91 3
2001 03 Tom 81 1
2001 03 Tom 84 2
2001 03 Tom 87 3
6 rows selected.
SQL> Select year, empcode, name, position
2 From (Select year, empcode, name, position,
3 row_number() over (partition by year, empcode, name
4 order by year, empcode, name, position) as rn
5 From employees) emp
6 Where rn = 1;
YEAR EM NAME PO
2001 02 Scott 01
2001 03 Tom 81
SQL> -
How to select rows with min value on a specific column
I have a query:
select
m.x1,
round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
from
table1 m,
table2 l
where
l.x3 = m.x3 and
to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
and I got this result table:
x1 (ID)
numofdays
001
5
001
10
002
2
003
3
003
1
004
0
005
66
several ID's have multiple values on the second column, I want to have only distinct IDs with smallest "numofdays" like this:
x1 (ID)
numofdays
001
5
002
2
003
1
004
0
005
66
Any ideas?Hi,
The most general and versatile way is a Top-N Query:
WITH got_r_num AS
select
m.x1,
round (to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2, 0) as numofdays
, ROW_NUMBER () OVER ( PARTITION BY m.x1
ORDER BY to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') - m.x2
) AS r_num
from
table1 m,
table2 l
where
l.x3 = m.x3 and
to_date (l.y1, 'mm/dd/yyyy HH:MI:SS AM') >= TO_DATE('01012013','MMDDYYYY') and
SELECT x1, numofdays
FROM got_r_num
WHERE r_num = 1
If you'd care to post CREATE TABLE and INSERT statements for your sample data, then I could test it.
Notice that the sub-query (got_r_num) is exactly what you posted, only with a new column (r_num) added to the SELECT clause. -
How to present the data this way?
I have a table, which has three columns:
Actnbr ------ BeginDate --------EndDate-------- IntRate
123456789------ 01/20/2006----- 02/1/2006------ 8.00
123456789------ 02/2/2006----- 02/20/2006------5.00
123456789------ 02/20/2006----- 05/1/2006------ 4.00
123456789------ 05/1/2006----- 06/10/2006------4.00
123456789------ 6/10/2006----- <null>------ 8.00
987654321------ 01/10/2006----- <null> ------ 6.00
456789123------ 05/04/2006----- 05/05/2006------7.00
456789123------ 05/06/2006----- 08/10/2006------6.00
456789123------ 08/11/2006----- 09/20/2006------6.00
456789123------ 09/21/2006----- <null> ------ 5.00
789123456------ 05/9/2006----- 08/20/2006------8.00
more ...
I want the output like this:
Actnbr---- BeginDate--- EndDate---IntRate-- BeginDate-- EndDate--IntRate-- BeginDate-- EndDate--intRate--BeginDate--EndDate---IntRate-- BeginDate--EndDate-- IntRate
123456789--01/20/2006--02/1/2006-- 8.00-- 02/2/2006-- 02/20/2006-- 5.00--05/1/2006-- 06/10/2006--4.00----05/1/2006--06/10/2006--4.00-- 6/10/2006-- <null>--8.00
987654321--01/10/2006-- <null> -- 6.00
456789123--05/04/2006-- 5/5/2006-- 7.00--05/06/2006--08/10/2006-- 6.00--08/11/2006--09/20/2006--6.00--09/21/2006-- <null>-- 5.00
789123456--05/9/2006-- 8/20/2006--8.00
is it possible to get the output like above using just sql, if so, could you please share your thoughts with an example.
i used "-" to sepearte value for clarity.
Thanks in advance.this one solve ?
select AcctNbr || begindate || enddate || intrate || begindate || enddate || intrate from table_name;
or yout want sth like this?
SQL> select * from rup_data1;
OCCUPATI LONAMOUNT INCOME REF DECSIO
SAL 75 70 no ACCEPT
SAL 80 90 no REJECT
SAL 85 85 yes REJECT
SAL 72 95 yes REJECT
SAL 69 70 yes ACCEPT
72 90 no ACCEPT
PROFS 83 78 yes ACCEPT
PROFS 64 65 no ACCEPT
PROFS 81 75 yes ACCEPT
BUSINESS 71 80 no REJECT
BUSINESS 65 70 no REJECT
OCCUPATI LONAMOUNT INCOME REF DECSIO
BUSINESS 75 80 yes REJECT
BUSINESS 68 80 yes ACCEPT
BUSINESS 70 96 yes ACCEPT
14 rows selected.
SQL> SELECT concat_and_fn(newcol) FROM newformat ;
CONCAT_AND_FN(NEWCOL)
SAL7570noACCEPT and SAL8090noREJECT and SAL8585yesREJECT and SAL7295yesREJECT an
d SAL6970yesACCEPT and 7290noACCEPT and PROFS8378yesACCEPT and PROFS6465noACCEPT
and PROFS8175yesACCEPT and BUSINESS7180noREJECT and BUSINESS6570noREJECT and BU
SINESS7580yesREJECT and BUSINESS6880yesACCEPT and BUSINESS7096yesACCEPT
SQL>
pls align it ,
rgds
Rup
Maybe you are looking for
-
How to get the number of rows in a repeating frame ?
Hi all, When I launch a report from forms then sometimes there are data in the report and sometimes there are no data. And the problem is that when there are no data then the frame containing the repeating frame is still displaying and a blank page d
-
Unable to acess BPEL WSDL from OWSM Gateway
Hello all, I'm trying to register a BPEL Process as a service on a OWSM gateway. The BPEL WSLD is as follows: <definitions name="WR01" targetNamespace="http://xmlns.oracle.com/WR01"> − <types> − <schema attributeFormDefault="qualified" elem
-
FM for getting the org details
Hi all, Is there a function module, where i can give my Organisation(org) unit as an input and need to get the cost center, position(manager), org name attached to that org unit. I actually do not want to use RH_STRUC_GET. Your inputs highly appreci
-
[solved] vim starting in command mode?
I've been banging my head with this for a while, and my google-fu is failing me. Sometime not long ago, my vim installation started doing something strange: when I open it, or open a file, rather than starting in normal mode, it starts in command mod
-
Imported screen capture avi looks pixely in pp2 cs3
Okay this is my first post on here so please bear with me, I will try to make this any easy one. I am using Adobe Premiere Pro cs3 and I have been trying like mad to get a usable screen capture incorporated into my videos. I work for an internet comp