How do I extract a set of rows from a table based on specified criteria?
I am using Numbers '08. I have a table that looks like this:
I would like to, programmatically, find the MAX amount of all the 'Clothing' category items. More generally I'd like it to work like the COUNTIF function where I can do this:
MAX(INCLUDEIF('Table::Category', 'Clothing'))
I think my intention is clear.
I suppose an alternate way is to create a table for every category and just do a MAX over that table, but this seems redundant since I already have that data in this particular table. Thanks!
The easiest way, to me, is to add a new column to you data table which only shows values from rows that match the category for which you want to find the max():
The new column (in this example) is titled "Active Category" and is selected from a Summary table. Add a new table titled "Summary" as shown.
Make cell B2 contain the category.
Let's get the data table set up with the new column:
E2=IF(C2=Summary :: $B$2, D2, "")
select E2 and fill down. This will only show the amount IF the category in column C matches what you entered in the summary table:
Now let's complete the summary table:
B3=MAX(Data :: E)
I hope this helps
Similar Messages
-
How to bring the more than one rows from the table into the script
Hi
I have to bring more than one rows from the table into the Main windows of the script. so plz help me out.
Thanks in Advance
AnanyaHi Ananya,
Bring more than one row into main window of script.
For this you need to do some changes for data which you pass to main window.At a time you need to pass more than one row,so for this you need to define one structure.See below code.
Types:begin of ty_rows,
include structure (your row_structure),
include structure (your row_sturcture),
Types:end of ty_rows.
for example....
If i need to pass 2 vendor details at a time to main window then the structure should be like this.
Types:begin of ty_rows,
vendor1 like lfa1-lifnr,
vendor1_name like lfa1-name1,
vendor2 like lfa1-lifnr,
vendor2_name like lfa1-name1,
end of ty_rows.
Data:i_main type standard table of ty_rows,
wa_main type ty_rows.
Based on condition you can pass more than one rows of your actual internal table data to i_main internal table.
Then you can pass i_main internal table to your main window.
I think this will help you.
Cheers,
Bujji -
How to get a block of data from internal table based on a criteria
Hi all,
I have some records in the internal table t_int1. I want to retrieve some set records from that table and put them all in some other table, based on a single field which is not a key. Can i use READ statement to achieve this.
Could you please let me know any simple way of doin this.
Regards,
VishnuI have some records in the internal table t_int1. I want to retrieve some set records from that table and put them all in some other table, based on a single field which is not a key. Can i use READ statement to achieve this.
Could you please let me know any simple way of doin this.
Answer :
data:
itab2 like standard table of t_int1 with header line.
Loop at t_int1.
read table t_int1 with index 1.
check ur condition----
check each line and insert it ---work out the syntax for this
IF t_int1-xyz = data1
append line of t_int1 to itab2. or try insert
cnt = cnt + 1 -
u will get no. of records added to next itab.
else.
cnt1 = cnt1 + 1 -
u will get no. of records not added to next itab.
endif.
end loop. -
Extracting information from a table based on different criteria
Post Author: shineysideup
CA Forum: Formula
Hi Folks
I have a bit of a strange one here.
I need to extract information from a single table based on different critera.
Sounds simple enough but here's the tricky part.
This table is a table that contains the build of a product. All the parts that are used to make the product and also the sub-parts that are used to make the primary product parts.
Example:
I have a part that is in the product and the part no is 1111. This part is actually part of another part that is part no 1112
What I need to do is display part no 1111 with all of its details but then also show that it is also part of part no 1112.
The way the table holds this information is as follows.
Seq_No Parent_Seq_No Part_No
The seq_no is item no that is given to the part number. If the part is a member of another part then there is also a parent_seq_no.
Everything needs to tie back to the seq_no and the parent_seq no as the part itself can be used in a parent or it can be used on its own. This way you can actually have the same part appearing in the list several times but the seq_no will be different for each one. If the part can be used in two different sub-builds (with each part being used twice in each sub-build) and also on its own once then you would have 5 different seq_nos two parent_seq_nos.
What I need to do is to list all of the parts but then also when a part is part of a parent_seq_no I need to be able to display the parent seqno but also the part_no for that as the parent would also be listed as an individual item in the part list.
At the moment listing the part_no, seq_no and parent_seq_no is easy but when I try to list the part_no for the parent I jsut keep getting the original sub part again. I can do this with a sub-report but with what I need to do with the data after listing the parts a sub-report is not an option for me.
This make sense?
ThanksPost Author: Charliy
CA Forum: Formula
As long as the chain only goes one link deep, you should be able to Alias the table and link it (left outer) from the child part to the parent part. Then build a Detail B (or Group Footer if that's where you're printing) and conditionally suppress is if there is no "Parent Part". -
Fetching more than one row from a table after selecting one value from the dropdown
Hi Experts,
How can we fetch more than one row from a table after selecting one value from the dropdown.
The scenario is that I have some entries in the dropdown like below
A B C
11256 VID 911256
11256 VID 811256
11256 SONY 11256
The 'B' values are there in the dropdown. I have removed the duplicate entries from the dropdown so now the dropdownlist has only two values.for eg- 'VID' and'SONY'. So now, after selecting 'VID' from the dropdown I should get all the 'C' values. After this the "C' values are to be passed to other methods to fetch some data from other tables.
Request your help on this.
Thanks,
Preeetam Narkhede.Hi Preetam!
I hope I understand your request proberly, since this is more about Java and less about WebDynpro, but if I'm wrong, just follow up on this.
Supposed you have some collection of your original table data stored in variable "origin". Populate a Hashtable using the values from column "B" (let's assume it's Strings) as keys and an ArrayList of whatever "C" is (let's assume String instances, too) as value (there's a lot of ways to iterate over whatever your datasource is, and since we do not know what your datasource is, maybe you'll have to follow another approach to get b and c vaues,but the principle should remain the same):
// Declare a private variable for your Data at the appropriate place in your code
private Hashtable temp = new Hashtable<String, ArrayList<String>>();
// Then, in the method you use to retrieve backend data and populate the dropdown,
// populate the Hashtable, too
Iterator<TableData> a = origin.iterator();
while (a.hasNext()) {
TableData current = a.next();
String b = current.getB();
String c = current.getC();
ArrayList<String> values = this.temp.get(b);
if (values == null) {
values = new ArrayList<String>();
values.add(c);
this.temp.put(b, values);
So after this, you'll have a Hashtable with the B values als keys and collections of C values of this particular B as value:
VID --> (911256, 811256)
SONY --> (11256)
Use
temp.keySet()
to populate your dropdown.
After the user selects an entry from the dropdown (let's say stored in variable selectedB), you will be able to retrieve the collection of c's from your Hashtable
// In the metod you handle the selection event with, get the c value collection
//and use it to select from your other table
ArrayList<String> selectedCs = this.temp.get(selectedB);
// now iterate over the selectedCs items and use each of these
//to continue retrieving whatever data you need...
for (String oneC : selectedCs) {
// Select Data from backend using oneC in the where-Clause or whatever...
Hope that helps
Michael -
How do I export a specific set of rows from Numbers?
What i am looking to be able to do is
Export a specific set of rows from Numbers
I am working with large files of information
but would like to break the file up into smaller files
for example
I have 1 file with 40,000 rows
I need to be able to export/save this file into 4 smaller files
Rows 1-10,000
Rows 10,001-20,000
Rows 20,001-30,000
Rows 30,001-40,000I do not think I would use Numbers for this task.
I would duplicate the file (let's say the name is data.txt)
and name the two files:
dataA.txt
dataC.txt
then I would open dataA.txt in TextEdit and delete the last half of the file and save
then I would open dataC.txt in TextEdit and delete the first half of the file and save
then duplicate dataA.txt and name the new file dataB.txt
then duplicate dataC.txt and name the new file dataD.txt
Now open dataA.txt and delete the last half of the file, save
Now open dataB.txt and delete the first half of the file, save
Now open dataC.txt and delete the last half of the file, save
Now open dataD.txt and delete the first half of the file, save
if you did this very often I would suggest a script of some kind -
How can i update rows in a table based on a match from a select query
Hello
How can i update rows in a table based on a match from a select query fron two other tables with a update using sqlplus ?
Thanks Glenn
table1
attribute1 varchar2 (10)
attribute2 varchar2 (10)
processed varchar2 (10)
table2
attribute1 varchar2 (10)
table3
attribute2 varchar2 (10)
An example:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)Hi,
Etbin wrote:
Hi, Frank
taking nulls into account, what if some attributes are null ;) then the query should look like
NOT TESTED !
update table1 t1
set processed = 'Y'
where exists(select null
from table2
where lnnvl(attribute1 != t1.attribute1)
and exists(select null
from table3
where lnnvl(attribute2 != t1.attribute2)
and processed != 'Y'Regards
EtbinYes, you could do that. OP specifically requested something else:
wgdoig wrote:
set table1.processed = "Y"
where (table1.attribute1 = table2.attribute1)
and (table1.attribute2 = table3.attribute2)This WHERE clause won't be TRUE if any of the 4 attribute columns are NULL. It's debatable about what should be done when those columns are NULL.
But there is no argument about what needs to be done when processed is NULL.
OP didn't specifically say that the UPDATEshould or shouldn't be done on rows where processed was already 'Y'. You (quite rightly) introduced a condition that would prevent redo from being generated and triggers from firing unnecessarily; I'm just saying that we have to be careful that the same condition doesn't keep the row from being UPDATEd when it is necessary. -
Ora-30926 : unable to get a stable set of rows in source table
Dear All
When I try to load my cube I get the error "ora-30926 : unable to get a stable set of rows in source table".
Any idea? Googling for this error did not return any solutions.
My env:
source: Oracle 10g (10.2.x)
Target: Oracle 11g (11.1.0.7)
I am using warehouse builder 11.1.0.7 on Linux
thank youCarsten / neashton
Thanks for your help. Duplicate rows were the issue.
I finally debugged the problem to my time dimension.
The OWB wizard generated time dimension contains only date, but no time.
Unfortunately, for me to uniquely identify my data, I need to include time also (detailed in how do I include 'Time' in a time dimension? .
Since Carsten was the first one to answer this, I am awarding the points to him.
thanks a lot both of you
Edited by: T2 on Jun 2, 2009 4:01 AM -
How to compare two rows from two table with different data
how to compare two rows from two table with different data
e.g.
Table 1
ID DESC
1 aaa
2 bbb
3 ccc
Table 2
ID DESC
1 aaa
2 xxx
3 ccc
Result
2Create
table tab1(ID
int ,DE char(10))
Create
table tab2(ID
int ,DE char(10))
Insert
into tab1 Values
(1,'aaa')
Insert
into tab1 Values
(2,'bbb')
Insert
into tab1 Values(3,'ccc')
Insert
into tab1 Values(4,'dfe')
Insert
into tab2 Values
(1,'aaa')
Insert
into tab2 Values
(2,'xx')
Insert
into tab2 Values(3,'ccc')
Insert
into tab2 Values(6,'wdr')
SELECT
tab1.ID,tab2.ID
As T2 from tab1
FULL
join tab2 on tab1.ID
= tab2.ID
WHERE
BINARY_CHECKSUM(tab1.ID,tab1.DE)
<> BINARY_CHECKSUM(tab2.ID,tab2.DE)
OR tab1.ID
IS NULL
OR
tab2.ID IS
NULL
ID column considered as a primary Key
Apart from different record,Above query populate missing record in both tables.
Result Set
ID ID
2 2
4 NULL
NULL 6
ganeshk -
How can i distinguish between set or tuples from incoming filters in a calculation
How can i distinguish between set or tuples from incoming filters in a calculation. i am using descendants function with the leaves option to calculate some project revenue cause there is different calcuation method on sub projects the sum on the main project
should reflect the sum of the sub project with all different methods.
this works fine until i try to select 2 sub projects at the same time. i am getting the standard currentset dosnt work cause its a set.
is there i way i can check if its a multiple select or not and handle it a different wayHi,
Check the following link about Multi Select Calculations written by Mosha.
http://sqlblog.com/blogs/mosha/archive/2007/01/13/multiselect-friendly-mdx-for-calculations-looking-at-current-coordinate.aspx
Best regards...
Chandima Lakmal Fonseka -
How do I get and set column attributes in a table or a treetable with Java?
Using 11.1.1.4.0
Hi,
How do I get and set column attributes in a table or a treetable with Java? For a simple example, say I have a table and want certain roles to see all columns (including address), and other roles can see only certain columns (no address). In a Java method, I want to test if a table's column visible attribute is true and if so, set it to false before rendering it.
Thanks in advance,
TroyHi,
this use case would be a perfect example for using seeded MDS customization. Instead of checking what users are allowed to see or not upon rendering time, you have a customization class and thus the framework doing this for you.
http://www.oracle.com/technetwork/developer-tools/adf/learnmore/31-mds-sample-169173.pdf
In this paper and sample, specific users see different layouts. It also contains a customization class that shows how this can leverage ADF Security
Frank -
How to list all the rows from the table VBAK
Friends ,
How to list all the rows from the table VBAK.select query and the output list is appreciated.Hi,
IF you want to select all the rows for VBAK-
Write-
Data:itab type table of VBAK,
wa like line of itab.
SELECT * FROM VBAK into table itab.
Itab is the internal table with type VBAK.
Loop at itab into wa.
Write: wa-field1,
endloop. -
How NOT to restrict no of rows from two tables
I have two identical tables Invoice and Payment. The only difference is Invoice_id,Invoice_Amt and Payment_id,Payment_Amt columns that shows different ids and amounts. The bank_ids, names, account_types are same. Invoice table has 3 rows and Payment has 2. Simply meaning that there were 3 invoices generated but the bank received 2 payments. I want to show Invoice_Amt and Payment_Amt using sql query. But its giving me total 6 rows. Whereas, I want 3 from Invoice and 2 rows from Payment table to show side-by-side.
CREATE TABLE invoice
( invoice_id NUMBER
bank_id NUMBER,
bank_name VARCHAR2(256),
invoice_amount NUMBER);
----Invoice table has 3 rows showing 3 Invoice Amts
CREATE TABLE payment
( payment_id NUMBER
bank_id NUMBER,
bank_name VARCHAR2(256),
payment_amount NUMBER);
----Payment table has 2 rows showing 2 Payments
After executing this sql statement below, I get 6 rows:
select inv.invoice_amount,pymt.payment_amount from invoice inv,payment pymt where inv.bank_id=pymt.bank_id;
How can I show 3 rows for Invoice and 2 for Payment..?
Thank you.Hi,
So you want
the 1st invoice to appear side-by-side with the 1st payment,
the 2nd invoice to appear side-by-side with the 2nd payment,
the nth invoice to appear side-by-side with the nth payment.
But, if there are an uneqaul numner of payments and invoices, all the payments and all the invoices must still be shown, alone on a row if necessary.
That sounds like a job for FULL OUTER JOIN.
Use the analytic ROW_NUMBER fucntion to determine which is the 1st, 2nd, ..., nth row in each table, for each bank.
WITH invoice_plus_r_num AS
SELECT bank_id, bank_name
, invoice_amount
, ROW_NUMBER () OVER ( PARTITION BY bank_id, bank_name
ORDER BY invoice_id
) AS r_num
FROM invoice
, payment_plus_r_num AS
SELECT bank_id, bank_name
, payment_amount
, ROW_NUMBER () OVER ( PARTITION BY bank_id, bank_name
ORDER BY payment_id
) AS r_num
FROM payment
SELECT NVL (i.bank_id, p.bank_id) AS bank_id
, NVL (i.bank_name, p.bank_name) AS bank_name
, i.invoice_amount
, p.payment_amount
FROM invoice_plus_r_num i
FULL OUTER JOIN payment_plus_r_num p ON i.bank_id = p.bank_id
AND i.bank_name = p.bank_name
AND i.r_num = p.r_num
ORDER BY bank_id -- you can use column aliases here
, bank_name
, NVL (i.r_num, p.r_num)
;You mentioned something about accounts, but didn't include that in the CREATE TABLE statements. You'll probably want to add that wherever I used bank_id and bank_name, above.
Are invoce and payment actually views, rather than tables? If not, you should have a separate bank table, and only include the bank_id in the other tables.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
Edited by: Frank Kulash on Feb 3, 2011 12:32 PM -
How to fetch rows from a table like search engines do?
Is it possible to fetch rows from a table like Google does? I want to fetch row number 20-40 after the select has ordered the rows.
Pseudo code: select * from log where rownum > 20 and rownum < 40 order by date;
Rownum doesn't work with ordering so I tried:
select * from log where (select * from log order by date) and rownum <20;
But that still doesn't do what I want. I get the "top 20" rows but I can't get rows 20-40.
My real table has 70000 rows and I want to select 69000-70000 so I really need a SQL do fetch only the rows I need.
Any help would be very appreciated!
Best regards,
Christer NordvikSELECT alias_for_rownum, column_names
FROM (SELECT ROWNUM AS alias_for_rownum, column_names
FROM (SELECT column_names
FROM table_name
ORDER BY columns_to_order_by)
WHERE ROWNUM <= last_row_you_want)
WHERE alias_for_rownum >= first_row_you_want
Example:
-- (This example uses the Oracle dept demo table.
SET AUTOTRACE ON EXPLAIN
SELECT rn, deptno, dname, loc
FROM (SELECT ROWNUM AS rn, deptno, dname, loc
FROM (SELECT deptno, dname, loc
FROM dept
ORDER BY deptno)
WHERE ROWNUM <= 3)
WHERE rn >= 2
RN DEPTNO DNAME LOC
2 20 RESEARCH DALLAS
3 30 SALES CHICAGO -
How to save the selected rows from Advance table into database
Hi
I have requirement like..
In custom page , Manager Search the Candidates and selects the candidate ROWS from advance table.
The reqt is how to save the selected multiple rows into the database.hi Reetesh,
In Custom page
Supoose the Recruiter Search is for Position Finance Mangager , it retrieves 100 rows , out of which Recruiter select 10 rows .
So in Such scenario how to save this 10 rows against Recruiter
, i mean , Is i need to create custom table, to save Recruiter , these selected 10 rows.
I hope u understand my question
Maybe you are looking for
-
Ipod Nano error message when trying to synch
Im having problems with my ipod nano it keeps giving me the error "The ipod cannot be synched.The required folder cannot be found" Also gives me "some of the items in the itunes library were not copied to the ipod because one or more errors occurred"
-
Calendar & photos not synching between iphone 5s and ipad mini
Calendar and photos won't synch between iphone and calendar, contacts & notes work OK - been through all recommended support steps & all seems set up properly -any ideas plse?
-
MacBook keeps crashing needing hard restart, related to Office 08???
Please forgive me if this is in the wrong thread, this is my first time posting; I really couldn't figure out where this should go; I won't be offended if it gets moved. For quite some time now, about a year and a half, every so often my computer wou
-
Whe I try to log into the agent, I get a sytem is offline message. This is the trace I see from the CTI Server.. Any help would be greatly appreciated, im started to get very annoyed at this :) Thanks, Chad Trace: >> RCV CG: [call.5001.25713588]:EVT:
-
Prevent Jabber account from going idle
I have a Jabber account that automatically goes Idle (yellow dot) after a certain amount of time. Is there a way to prevent this from happening? I've checked up and down in Messages > Preferences and can't seem to find an option to change this. Thank