Sorting rows in a table
I had a really nice spreadsheet in Appleworks on my G3. Now I just got an iMac with Snow Leopard, so I have to translate all my work to iWork. This spreadsheet opens Pages when I click on it (I would have thought it should be Numbers, but whatever). Now when I select a range of cells and I want to sort them, the "help" tells me that table inspector-edit rows and columns-sort ascending ought to do this. However when I have a range selected, "sort ascending" is greyed out. It is only available if I want to sort the entire spreadsheet; the minute I select specific cells the sort option becomes unavailable. What am I doing wrong? This was sure so much easier with Appleworks. Way, way easier.
Just because you have a new Mac with Snow Leopard doesn't mean you can't run AppleWorks, but converting files to iWork is a very good idea. Having AppleWorks on the new Mac will make converting the files easier.
You can copy the whole AppleWorks 6 folder to a CD (this gives you a backup so you don't have to go through this again) or flash drive & then copy the AppleWorks 6 folder to the Applications folder on your Snow Leopard Mac. AppleWorks will create any preferences & other support files needed as long as you have the whole AppleWorks 6 folder.
AppleWorks 6 spreadsheets can be opened by Numbers, not Pages. Pages can only open AppleWorks 6 word processing documents.
Similar Messages
-
Hello...is it possible to sort rows of text alphabetically in a table created in ID? Can't find any reference to that in Help.
Thanks!
LisaSounds like your easiest solution is to use the ORDER BY clause in your SQL statement:
http://www.w3schools.com/sql/sql_orderby.asp
If that won't do the trick, this might help:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
(see Sorting and Otherwise Manipulating Data toward the bottom) -
i have a table, where the cells are populated by String returns from a SQL statement.
The table populates fine and all information is correctly displayed, but is there anyway to sort the rows of the table once they are populated?
i have an amount column in the table and i want to be able to sort the table in order of highest amount first...this doesnt need to be changeable later by the user, it just needs to be sorted on display......any one have any ideas?Sounds like your easiest solution is to use the ORDER BY clause in your SQL statement:
http://www.w3schools.com/sql/sql_orderby.asp
If that won't do the trick, this might help:
http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
(see Sorting and Otherwise Manipulating Data toward the bottom) -
How to identify date & time of insertion of rows in a table
Hi,
Is it possible to identify the date & time of insertion of rows in a table?
for example:
Table name: emp
I have rows like this
emp_code name dept
pr01 ram edp
ac05 gowri civil
pr02 sam pro
i want to know the date and time of the insertion this( ac05 gowri civil).
Could you please help me.....
Thanks in advance....psram wrote:
sorry for the confusion. I dont want to store date and time. I said that for example only.
I have table which consists of thousands of rows. I want to know the insertion date & time of a particular row.
Is it possible?So, if I have a table that stores a load of employee numbers, do you think I could get the database to tell me their names?
If you don't store the information, you can't query the information.
Ok, there are some dribbs and drabbs of information available from the back end of the database via the SCN's, Archive Logs etc., but those sort of things disappear or get overwritten as time goes by. The only way to know the information it to ensure you store it in the first place.
So, in answer to your question, No, there isn't a true and reliable way to get the data/time that rows were inserted into the table, unless you have chosen to store it alongside the data. -
How to find number of rows in a table
i have one table ,it contains millions of record,how can i know number of rows in that table without using count(*),
i tried in user_table ,for the column NUM_ROWS,but it is not showing number of rows,pls send me a solution for this.
regards,
singhOk, that only was to show simply that max option
might not an option to reduce execution time.Yes, but I/O variances have a tendency to really skew the observed elapsed execution time - making execution time alone a poor choice to determine what SQL will perform better than another.
Both MAX(ROWNUM) and COUNT(*) results in the same amount of I/O - as both uses the exact same execution plan, I/O wise. In this example, a FTS.
SQL> create table testtab nologging as select * from all_objects where rownum < 10001;
Table created.
-- warmed up the buffer cache with a couple of SELECTs against TESTAB in order
-- to discard PIOs from the results
SQL> set autotrace on
SQL> select count(*) from testtab;
COUNT(*)
10000
Execution Plan
Plan hash value: 2656308840
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
0 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
223 bytes sent via SQL*Net to client
238 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select max(rownum) from testtab;
MAX(ROWNUM)
10000
Execution Plan
Plan hash value: 2387991791
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 35 (9)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | COUNT | | | | |
| 3 | TABLE ACCESS FULL| TESTTAB | 9262 | 35 (9)| 00:00:01 |
Note
- dynamic sampling used for this statement
Statistics
0 recursive calls
0 db block gets
131 consistent gets
0 physical reads
0 redo size
225 bytes sent via SQL*Net to client
238 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
So seeing that we have the exact same baseline for both queries, and that PIO does not influence the results, we time a 1000 executions of both.
SQL> declare
2 cnt number;
3 begin
4 for i in 1..1000
5 loop
6 select count(*) into cnt from testtab;
7 end loop;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:03.19
SQL>
SQL> declare
2 cnt number;
3 begin
4 for i in 1..1000
5 loop
6 select max(rownum) into cnt from testtab;
7 end loop;
8 end;
9 /
PL/SQL procedure successfully completed.
Elapsed: 00:00:15.87
SQL>
This shows that what makes the MAX() more expensive is just that - determining the MAX(). For each row, Oracle has to call its internal MAX() function with two values - the current max result and the new value. This function then returns the new max value. This overhead per row adds up to a significant overhead in execution time - making the MAX() approach 5x slower than the COUNT() approach. -
How to find middle row in a table ?
Hi Friends,
Is it possible to find middle row in a table by SQL Query.
KarTiK.Solution: sort the rows in order to create an ordered
sequence and then there will be a "middle row".Well, not quite.
If there are an odd number of rows then, yes, there will be a middle row in an ordered sequence, however if there is an even number of rows then the middle is between two rows... or... you could take it as the two rows either side of the middle....
SQL> select * from emp order by empno;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17/12/1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20/02/1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22/02/1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02/04/1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28/09/1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
7839 KING PRESIDENT 17/11/1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08/09/1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23/05/1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03/12/1981 00:00:00 950 30
7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23/01/1982 00:00:00 1300 10
14 rows selected.
SQL> select e.empno, e.ename, e.job, e.mgr, e.hiredate, e.sal, e.comm, e.deptno
2 from (select emp.*, row_number() over (order by empno) as rn from emp) e
3 ,(select round(count(*)/2) as middle, round(((count(*)+1)/2)) as middle2 from emp) m
4 where e.rn in (m.middle, m.middle2)
5 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
SQL> insert into emp values (1111, 'WILLIS', 'CLERK', 7902, sysdate, 900, null, 20);
1 row created.
SQL> select * from emp order by empno;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
1111 WILLIS CLERK 7902 18/01/2008 12:18:14 900 20
7369 SMITH CLERK 7902 17/12/1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20/02/1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22/02/1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02/04/1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28/09/1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01/05/1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
7839 KING PRESIDENT 17/11/1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08/09/1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23/05/1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03/12/1981 00:00:00 950 30
7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23/01/1982 00:00:00 1300 10
15 rows selected.
SQL> select e.empno, e.ename, e.job, e.mgr, e.hiredate, e.sal, e.comm, e.deptno
2 from (select emp.*, row_number() over (order by empno) as rn from emp) e
3 ,(select round(count(*)/2) as middle, round(((count(*)+1)/2)) as middle2 from emp) m
4 where e.rn in (m.middle, m.middle2)
5 /
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7782 CLARK MANAGER 7839 09/06/1981 00:00:00 2450 10
SQL> -
How to: Display Last n Rows in a table
I am currently running Crystal Reports XI and have been tasked with developing a report that displays only the last 30 rows in a table in ascending order (the records are used for showing data trends over time in a line graph). I have created a Command to extract the records, and by using the TOP 30 statement I can get the first 30 rows in proper order; however, in order to get the last 30 rows I have to sort the records in descending order. This gives me the last 30 rows that I need, but the data is in descending order. Is there another way to get the last 30 rows in a table so that the records come out in ascending order?
The Command I am using looks like this:
SELECT TOP 30 ROWID FROM MYTABLE ORDER BY ROWID DESC
(The ROWID field is alpha numeric)Hi,
Create a Group based on Rowid in the order-Ascending. This Group should contain all the fields that you require to print along with Rowid. Therafter insert Summary like sum,count etc for for any field within the group of the type numbervar(numeric). This would activate the Group Sort Expert in the Report Menu. Click on it and select Bottom N (with N as 30) within nature of Sort and suppy the fieldname as Rowid.
Hope this solves.....
Thanks,
Amogh. -
How do I get the numbers ipad app to plot a graph of dates against values, where the most recent date is on the right of the graph, but the most recent date is at the top rather than bottom of the rows in the table?
Also how can it be a line graph without plotting a circle at each value?
Thanks this is very frustratingMake a copy of the table and produce your Line chart or Bar chart from the copy. Sort the copy into the order you want to see in your chart.
Alternately you could use a Scatter Chart...
Jerry -
Processed rows in ADF Table are unsorted
I have to process the selected rows of an ADF table programmatically. This is not so difficult, like in the [example |http://www.johnbrunswick.com/2011/08/adftable-get-selected-row-or-rows/] below.
But the rows are processes in a random, unsorted manner. I need them to be processed sorted as they appear on screen. I think I set all properties correctly, at least the data appear sorted on the view.
Beside the solution this problem seems to give interesting information about how the iterators work internally. Thanks in advance.
public String cbSelectMany_action() {
// For learning purposes - show Select Many Button clicked
System.out.println("Select Many Button has been Clicked");
// RowKeySet Object can hold the selected rows from a user as follows
RowKeySet rksSelectedRows =
this.getTsupportIssues().getSelectedRowKeys();
// Iterator object provides the ability to use hasNext(), next() and remove() against the selected rows
Iterator itrSelectedRows = rksSelectedRows.iterator();
// Get the data control that is bound to the table - e.g. OpenSupportItemsIterator
DCBindingContainer bindings =
(DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding dcIteratorBindings =
bindings.findIteratorBinding("OpenSupportItemsIterator");
// Information from binding that is specific to the rows
RowSetIterator rsiSelectedRows =
dcIteratorBindings.getRowSetIterator();
// Loop through selected rows
while (itrSelectedRows.hasNext()) {
// Get key for selected row
Key key = (Key)((List)itrSelectedRows.next()).get(0);
// Use the key to get the data from the above binding that is related to the row
Row myRow = rsiSelectedRows.getRow(key);
// Display attribute of row in console output - would generally be bound to a UI component like a Label and or used to call another proces
System.out.println(myRow.getAttribute("IssueID"));
return null;
}Edited by: KaiMoeller on 17.10.2012 11:12Kai,
I don't think you can archive this without more coding, as the RowKeySet is a set which does not retain the order of the elements. So the solution would be to get the selected rows and then sort them as the table is currently sorted.
Happy coding
Timo -
Remove a row from multiple tables
Hello,
I have a form that has what appears to be one table. Since I needed 30 columns (29 of them are single character fields) I had to use 2 table objects. Then I needed the ability to add and remove rows. Adding a row at the end is easy enough. Deleting a specific row is the problem. At the moment, I added a third table which has a header row and a item body row. the body row is a button with the intention of removing that entire row from the large table. This means it needs to remove the row from all 3 tables.
My structure is:
form1
(Some other flowed subform that doesn't matter for us)
SubformPersonnel (a flowed subform)
SubformHeader (a positioned subform)
TextOverallHeader (text to label the oeverall 3 tables)
ButtonAddRow (adds a row to the end of all 3 tables)
SubformPersonnelTable (a positioned subform)
ContractorTableRemove (a table with 1 column for the Remove button)
HeaderRow (A hidden row to align the table with the other 2)
Item (A row with the Remove button)CellRemoveButton (the cell with the remove button and associated JavaScript)
ContractorTableLeft (a table with the left 15 printed columns)
HeaderRow
Contractor (A row of data to be removed when CellButton above is clicked)
ContractorTableRight (a table with the right 15 printed columns)
HeaderRow
Contractor (A row of data to be removed when CellButton above is clicked)
(Some other flowed subforms that I am not worried about at the moment)
The 3 tables are aligned so the headers all line up, with no spaces between them. The body rows then line up and this looks like one large table. From left to right, they are:
ContractorTableRemove, ContractorTableLeft, ContractorTableRight
So Item and Contractor rows are added when ButtonAddRow is clicked in the overall header. The intial count is set to 8 for each table, so I get 8 rows at startup. The minimum count is set to 1 for each. I know that each row of each table has the same index number because I filled those into a cell in each table durig the cell's initialize. This line, in the CellRemoveButton's click event deletes that cell's row in that table:
this.parent.parent._Item.removeInstance(this.parent.index);
I have tried all sorts of ways to delete the same row (using same index #) in the other 2 tables: ContractorTableLeft and ContractorTableRight, but don't seem to be getting the correct syntax correct. I have tried hard coding the references, using .parent as shown below, and also tried using an index of 1 just to try deleting a row with no results.
this.parent.parent.parent.ContractorTableLeft._Contractor.removeInstance(this.parent.inde x);
Can someone get me the correct syntax here?
I have seen examples of putting a hidden delete button on each table and clicking that, but I am concerned that it will get in the way of the tables on either side of the table it is in. I reeally want to just reference the row and remove it so I can avoid any problems these additional delete problems may cause.
I have copied the form to https://acrobat.com/#d=7M8R50rEHf4AaVXppwyKLwThank you, Niall. Much appreciated!
The Delete button was more to make sure one could delete these outside a button in the actual row and I see I had the index wrong such that I was deleting the second row and not the first. I had toyed with using this as a hidden button if I could pass the index to the event's function.
I had not thought of adding the reference to each row as a variable. It seems to work very well.
For future reference to others, here is the code from the cellRemoveButton click event:
// Declare some variables
var i = this.parent.index;
var oContractorLeft = ContractorTableLeft.Contractor;
var oContractorRight = ContractorTableRight.Contractor;
// Remove this row by accessing its index within the set of 'Item' row instances of the parent table
_Item.removeInstance(i);
// Since this table is actually 3 tables, we need to remove the other two table's instances as well.
// Their index should be the same, so we just need to get their names correct.
oContractorLeft.instanceManager.removeInstance(i);
oContractorRight.instanceManager.removeInstance(i);
// removing the row doesn't trigger calculations in tables in the form's current target (fixed in later versions of Acrobat)
// force calculations to fire so the ItemIndex field's value is updated according to the remaining row's indexes
// see http://forms.stefcameron.com/2006/05/20/add-recalculate/
xfa.form.recalculate(1);
Again, thank you!
Karl -
Sort rows by fill color?
Is it possible in Numbers to sort rows based on the row fill color? There are only 2 colors the rows have as background (fill), and it would save time to sort based on the highlighted row. Any ideas?
Thank you-I agree with jerrold.
I will certainly not ask Apple for such a feature.
Here is a script which may give you an efficient response.
property columnOffset : 2
tell application "Numbers"
activate
set {rName, tName, sName, dName} to my getSelection()
if (character 2 of rName) as text > "9" then
set columnLetter to text 1 thru 2 of rName
else
set columnLetter to character 1 of rName
end if
set twoNames to my decoupe(rName, ":")
set {colNum1, rowNum1} to my decipher(item 1 of twoNames)
set columnToSort to colNum1 + columnOffset
tell document dName to tell sheet sName to tell table tName
set myColor to background color of (get properties of range rName)
set nbRows to count rows
repeat with r from 1 to 14 --nbRows
set val to background color of (get properties of range (columnLetter & r & ":" & columnLetter & r))
set val to (val is myColor)
set value of cell r of column columnToSort to val
end repeat
end tell
end tell
--=====
on getSelection()
local mySelectedRanges, sheetRanges, thisRange, _, myRange, myTable, mySheet, myDoc, mySelection
tell application "Numbers"
activate
tell document 1
set mySelectedRanges to selection range of every table of every sheet
repeat with sheetRanges in mySelectedRanges
repeat with thisRange in sheetRanges
if contents of thisRange is not missing value then
try
--return thisRange --poorly formed result
thisRange as text
on error errMsg number errNum
set {_, myRange, _, myTable, _, mySheet, _, myDoc} to my decoupe(errMsg, quote)
--set mySelection to (a reference to (range rn of table tn of sheet sn))
return {myRange, myTable, mySheet, myDoc}
end try
end if -- contents…
end repeat -- thisRange
end repeat -- sheetRanges
end tell -- document 1
end tell -- application
return {missing value, missing value, missing value, missing value}
end getSelection
--=====
on decipher(n)
local letters, colNum, rowNum
set letters to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
if (character 2 of n) as text > "9" then
set colNum to (offset of (character 1 of n) in letters) * 64 + (offset of (character 2 of n) in letters)
set rowNum to (text 3 thru -1 of n) as integer
else
set colNum to offset of (character 1 of n) in letters
set rowNum to (text 2 thru -1 of n) as integer
end if
return {colNum, rowNum}
end decipher
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
Select a cell with the color to use in the sort.
Run the script.
It will fill the column whose offset from the selected one is defined by the property 'columnOffset'
If the background of the cell in the source column is the searched one the value will be 1
if the background is not this one, the value will be 0.
So it will be easy to use a condition.
Yvan KOENIG (from FRANCE mardi 10 mars 2009 20:39:44) -
How do I turn off the shading on the first row of my Table?
I have to type a lot of information in, and managed to get a "Table" going in my Pages Document.
Unfortunately, and for a reason that seems to be inexplicable to me, the top row of the table is shaded. Sort of like a Half-tone or Zippatone sort of graphic effect. Or whatever you call it. Maybe a lot of people like that sort of thing, but not me.
How do I turn off the shading on the top row of my table?The top row of the table is a header row, the 1st column is too. They are both light grey to differentiate them from normal rows and columns.
If you don't need the special headers you can remove them. Select & right click Delete works as does turning them off using the table icons on the right of the format bar.
If you need the headers but don't like the colour just remove it via the fill option on the format bar and in the inspector.
The pdf guide will help to get you up to speed too. -
Sort rows in JTable except the last row
Hi All,
I have a JTable, which contains columns with numbers. The last row contains column sums.
I want to be able to sort rows, but the last row with sums must remain motionless.
Does anyone know the solution of this problem?
Thanks in advance.These two posts are my example. It works pretty good but there is one significant niggle - when moving a column the 'total' table does not move smoothly but it does move. I look forward to 'camickr' reducing this to about 1 line.
Part A.
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Font;
import java.text.DecimalFormat;
import java.util.Comparator;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.TableColumnModelEvent;
import javax.swing.event.TableColumnModelListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
public class Sabre20090331
static private class TotalizingTableComponent extends JScrollPane
private TotalizingTableComponent(final TableModel tableModel)
final SecondaryTableModel secondaryTableModel = new SecondaryTableModel(tableModel);
final JTable secondaryTable = new JTable(secondaryTableModel);
for (int i = 1; i < secondaryTableModel.getColumnCount(); i++)
secondaryTable.getColumnModel().getColumn(i).setCellRenderer(new NumberCellRenderer());
secondaryTable.getColumnModel().getColumn(0).setCellRenderer(new TitleCellRenderer());
final TableColumnModel secondaryTableColumnModel = secondaryTable.getColumnModel();
secondaryTable.setRowSelectionAllowed(false);
final JTable primaryTable = new JTable(tableModel);
for (int i = 1; i < tableModel.getColumnCount(); i++)
primaryTable.getColumnModel().getColumn(i).setCellRenderer(new NumberCellRenderer());
final TableRowSorter<TableModel> sorter = new TableRowSorter<TableModel>(tableModel);
final DoubleComparator doubleComparator = new DoubleComparator();
for (int i = 1; i < tableModel.getColumnCount(); i++)
sorter.setComparator(i, doubleComparator);
primaryTable.setRowSorter(sorter);
primaryTable.getColumnModel().addColumnModelListener(new TableColumnModelListener()
@Override
public void columnAdded(TableColumnModelEvent e)
// System.out.println("columnAdded()" + e);
@Override
public void columnRemoved(TableColumnModelEvent e)
// System.out.println("columnRemoved()" + e);
@Override
public void columnMoved(TableColumnModelEvent e)
//System.out.println("columnMoved()" + e);
secondaryTableColumnModel.moveColumn(e.getFromIndex(), e.getToIndex());
@Override
public void columnMarginChanged(ChangeEvent e)
//System.out.println("columnMarginChanged()" + e);
final TableColumnModel cm = (TableColumnModel) e.getSource();
for (int i = 0; i < cm.getColumnCount(); i++)
secondaryTableColumnModel.getColumn(i).setPreferredWidth(cm.getColumn(i).getWidth());
@Override
public void columnSelectionChanged(ListSelectionEvent e)
//System.out.println("columnSelectionChanged()" + e);
final JTableHeader primaryHeader = primaryTable.getTableHeader();
JPanel inner = new JPanel(new BorderLayout());
this.setColumnHeaderView(primaryHeader);
this.setViewportView(inner);
inner.add(primaryTable, BorderLayout.NORTH);
inner.add(secondaryTable, BorderLayout.CENTER);
public static void main(String[] args)
final JFrame frame = new JFrame("Totalizing JTable Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
final TableModel tableModel = new PrimaryTableModel();
frame.setContentPane(new TotalizingTableComponent(tableModel));
frame.pack();
frame.setVisible(true);
}Edited by: sabre150 on Apr 1, 2009 9:21 AM
Changed the layout of the inner panel so that the secondary table is now in the CENTER. This stops the secondary table becoming detached from the primary when one expands the frame beyond the prefferred size. -
Hi ,
I have a table with 20 records and 10 columns.I want to add columns from another table with out cross join.As others have said, you need to have some sort of join condition otherwise it is a cross join.
SQL> ed
Wrote file afiedt.buf
1 with T1 as (select 'e' as c1, 2 as c2 from dual union all
2 select 'd', 3 from dual)
3 ,T2 as (select 'x' as c3, 5 as c4 from dual union all
4 select 'y', 6 from dual union all
5 select 'z', 2 from dual)
6 --
7 select T2.c3, T2.c4, T1.c1, T1.c2
8 FROM (select c1, c2, row_number() over (order by c1) as rn from T1) T1
9 FULL OUTER JOIN
10 (select c3, c4, row_number() over (order by c3) as rn from T2) T2
11* ON (T1.rn = T2.rn)
SQL> /
C C4 C C2
x 5 d 3
y 6 e 2
z 2
SQL>This example assigns a row number to each row within each table and then joins using that row number.
(I've assumed the row number should be generated based on the order of the first column of each table, but you can change that as required).
What is the point of your requirement? -
Can one retrieve only the Nth row from a table?
Hi,
Can anyone explain the execution order of the below query to fetch the nth row data.
SELECT * FROM t1 a
WHERE n = (SELECT COUNT(rowid)
FROM t1 b
WHERE a.rowid >= b.rowid);
Thanks,
Satya.>
If you're interested in a more efficient way to get the Nth row of the table, in order by ROWID:
>
Perhaps you should change that to 'tremendously more efficient'?
Ran some tests of the two using a table that contained 50+ thousand records created from ALL_OBJECTS
CREATE TABLE EMP_ALL_OBJECTS AS SELECT * FROM ALL_OBJECTSThen ran your query (modified for the new table) for r_num = 10000. It returned immediately and used 925 consistent gets.
Ran the original query (modified for the new table) for '10000 = '. It took 3 minutes and used 24189252 consistent gets.
Thought maybe it was a fluke so ran the orginal query for '1 = '. It took the same 3 minutes and used 24189253 consistent gets.
Maybe someone else could try to reproduce these results?
Here is the plan for Frank's query
>
Execution Plan
Plan hash value: 3171438729
| Id | Operation | Name | Rows | Bytes |TempSpc| Cos
t (%CPU)| Time |
| 0 | SELECT STATEMENT | | 47057 | 7858K| | 19
93 (1)| 00:00:24 |
|* 1 | VIEW | | 47057 | 7858K| | 19
93 (1)| 00:00:24 |
|* 2 | WINDOW SORT PUSHED RANK| | 47057 | 7812K| 9664K| 19
93 (1)| 00:00:24 |
| 3 | TABLE ACCESS FULL | ALL_OBJECTS_EMP | 47057 | 7812K| | 2
39 (1)| 00:00:03 |
Predicate Information (identified by operation id):
1 - filter("R_NUM"=10000)
2 - filter(ROW_NUMBER() OVER ( ORDER BY ROWID)<=10000)
Note
- dynamic sampling used for this statement (level=2)
Statistics
0 recursive calls
0 db block gets
866 consistent gets
0 physical reads
0 redo size
1281 bytes sent via SQL*Net to client
407 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
>
And the plan for the original query
>
Execution Plan
Plan hash value: 308981268
| Id | Operation | Name | Rows | Bytes | Cost (
%CPU)| Time |
| 0 | SELECT STATEMENT | | 471 | 80070 | 10M
(1)| 35:14:03 |
|* 1 | FILTER | | | |
| |
| 2 | TABLE ACCESS FULL | ALL_OBJECTS_EMP | 47057 | 7812K| 239
(1)| 00:00:03 |
| 3 | SORT AGGREGATE | | 1 | 12 |
| |
|* 4 | TABLE ACCESS BY ROWID RANGE| ALL_OBJECTS_EMP | 2353 | 28236 | 238
(0)| 00:00:03 |
Predicate Information (identified by operation id):
1 - filter( (SELECT COUNT(ROWID) FROM "ALL_OBJECTS_EMP" "B" WHERE "B".ROWID<=
:B1)=1)
4 - access("B".ROWID<=:B1)
Note
- dynamic sampling used for this statement (level=2)
Statistics
7 recursive calls
0 db block gets
24189253 consistent gets
0 physical reads
0 redo size
1218 bytes sent via SQL*Net to client
408 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
>
Looks like the original query is doing a probe of the entire 2nd table for each row of the 1st table - almost a CARTESIAN result. It takes the same time no matter which record you are looking for.
Maybe you are looking for
-
HR runtime error on agent login/logout
Good afternoon. Has anyone run in a a runtime error when running agent login/logout reports? I am unable to run this report. a runtime error occurred while executing the inquiry. i know there used to be bugs on this but. uccx, ha,
-
How do I transfer files from a flash drive to my iPad? Do I need an adapter?
How do I transfer data from a flash drive to my iPad 2? Do I have to have an adapter or special device to do this?
-
RFC destination - INTEGRATION_DIRECTORY_HMI
While creating the <b>RFC destination - INTEGRATION_DIRECTORY_HMI</b>in the integration server, on logon & security tab, what is the user that should be given. As the source is ID, I thought it could be PIDIRUSER. Correct me -Naveen.
-
Looks like Intel Atom is not supported. Based on this review: http://www.theverge.com/2012/10/4/3447984/motorola-razr-i-review-intel-smartphone Any chance it will be supported in the future updates of Adobe AIR?
-
I just got the DINC2 and I'm wondering what parts of nfl mobile are free and what parts i have to pay for? i know i have to pay for live games but other videos seem to be free, there was no promp to pay for those. (this is a 3g phone)