Same column different rows
I have a table A
name num sal
a 12 25
a 15 20
a 31 30
a 19 50
b 30 21
b 50 52
b 13 70
a comes under b.
My task is to find the total num and sal of a.
select name,sum(num),sum(sal) from A group by name order by name gives me
name num sal
a 77 125
b 93 143
But my task is to sum these two rows also and get the output as :
name num sal
a 170 268
This is just the sample data. I can't alter the database.
Thanks
As other pointed out, your requirement is still unclear.
Maybe you are looking for rollup?
SQL> create table a
2 as
3 select 'a' name, 12 num, 25 sal from dual union all
4 select 'a', 15, 20 from dual union all
5 select 'a', 31, 30 from dual union all
6 select 'a', 19, 50 from dual union all
7 select 'b', 30, 21 from dual union all
8 select 'b', 50, 52 from dual union all
9 select 'b', 13, 70 from dual
10 /
Tabel is aangemaakt.
SQL> select nvl(name,'total') name
2 , sum(num)
3 , sum(sal)
4 from a
5 group by rollup(name)
6 /
NAME SUM(NUM) SUM(SAL)
a 77 125
b 93 143
total 170 268
3 rijen zijn geselecteerd.Regards,
Rob.
Similar Messages
-
Can I paste and keep the same columns and rows?
Paste problems. I regularly download data from the Transport for London, Oystercard website. When I used Windows I could highlight and copy on their webpage (displayed in columns and rows) and when I pasted into Excel it pasted the data in the same format (columns and rows). With iPages when I try this it pastes everything into a single downwards column. Paste and Match style does not seem to alter this just the font etc. Am I able to paste in iPages in the same format as I copy.
I'm guessing you're using Safari to access the web site. The problem is with Safari, not Pages (no "i") or Numbers. Safari just doesn't "understand" tables in web pages & puts lots of spaces and/or returns instead of the needed tabs. I long since gave up & use Camino or FireFox for copying the tables to Numbers or any other program I want the data separated by tabs. There are some web sites, Discover Card is one, that appear to have tables but the data doesn't copy as such.
-
Re: Report Painter Diff. formula in same column.
Hi,
I have some queries for report painter.
I have 2 columns, A & B. I've created column C and the first 5 row I would like to have a set of formula such as A10 and for the same column, the row 6 to 10 from column B, I want to have formulate B5-10.
My question is, whether it's posible to have 2 formula defined in the same column because value for each row may need to apply the formula differently.
Thx & RgdsYou can do this, although you need to split the columns into "Sections". You also need to remove the column headers so they are not repeated between each section.
They almost act similar to a page break, without actually breaking the column over pages.
http://help.sap.com/saphelp_47X200/helpdata/EN/c7/50673ad016ec32e10000000a11402f/frameset.htm
http://help.sap.com/saphelp_47X200/helpdata/EN/5b/d22d8a43c611d182b30000e829fbfe/frameset.htm
You can then have different calculated key figures within the same column.
To amend sections, go to Formatting > Section Overview/Section Layout. -
Multiple values from same column in diffetent columns in same row??
Hi all,
I am wondering how you can display different values from the same column into different columns on same row. For example using a CASE statement I can:
CASE WHEN CODE IN ('1', '3') THEN COUNT( ID) END as "Y"
CASE WHEN CODE NOT IN ('1', 'M') THEN COUNT( ID) END as "N"
Yes this will produce two columns needed but will also produce two separate records and null values for the empty's.
Any ideas?
ThanksIt's not clear what you want.
Can you post some examples as described in the FAQ: {message:id=9360002}
As my first guess, I would think you're looking for something like...
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-1980 00:00:00 800 20
7499 ALLEN SALESMAN 7698 20-FEB-1981 00:00:00 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-1981 00:00:00 1250 500 30
7566 JONES MANAGER 7839 02-APR-1981 00:00:00 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-1981 00:00:00 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-1981 00:00:00 2850 30
7782 CLARK MANAGER 7839 09-JUN-1981 00:00:00 2450 10
7788 SCOTT ANALYST 7566 19-APR-1987 00:00:00 3000 20
7839 KING PRESIDENT 17-NOV-1981 00:00:00 5000 10
7844 TURNER SALESMAN 7698 08-SEP-1981 00:00:00 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-1987 00:00:00 1100 20
7900 JAMES CLERK 7698 03-DEC-1981 00:00:00 950 30
7902 FORD ANALYST 7566 03-DEC-1981 00:00:00 3000 20
7934 MILLER CLERK 7782 23-JAN-1982 00:00:00 1300 10
14 rows selected.
SQL> select count(case when deptno in (10,20) then deptno end) as deptno_10_20
2 ,count(case when deptno > 20 then deptno end) as deptno_30plus
3 from emp;
DEPTNO_10_20 DEPTNO_30PLUS
8 6 -
I have a requirement to take a String column that allows multiple fields i.e. "101;102,103,104",
and using a SPD 2013 workflow I want to split there values and then insert each Values into different list as separate items.
Eg:
I have a LIST A with the columns CustID, CustName and LIST B with the same Column Name with the below values
LIST A:
Cust ID
CustName
101
ABC, XYZ, CTSS, WIPROS, TCSS
I want to insert the above comma separated values in the below format(different Row)
LIST B:
CustID
CustName
101
ABC
101
XYZ
101
CTSS
101
WIPROS
101
TCSSHi,
Here is a codeplex solution can meet your reference:
Plumsail String Workflow Actions for SharePoint 2013 and SharePoint Online
http://spworkflowactions.codeplex.com/
We can use Split string workflow action to split the CustName value, then insert it to ListB.
More information:
http://www.codeproject.com/Articles/749471/String-processing-workflow-actions-for-SharePoint
Best Regards
Dennis Guo
TechNet Community Support -
ALV List in the same Column for the row CELL i need button or value
Hi,
In my ALV list for the same column I need Button or Value for the different rows (CELL) depending upon my condition.
as well as I have to make read only of 3 rd column CELL based on my first column dropdown value CELL for this Row Only.
Depends upon the value in column 1 / row 2 I have to read only the CELL of column 5 / row 2 ie for the same row.
Depends upon the value in Column 1/ row 3 I have to EDITABLE or Button the CELL of column 5 / row 3 ie for the same row
How to do the logic for this.
I tried and got it for the entire column only.
But my requirement is for the sepecific cell in the column.
Kindly help to proceed further.
Thanks in advance.
DavHere is how you can make a particular cell in the row read-only based on certain conditions.
In my example I am displaying the flight details in an ALV. Here I am checking the airline id and if it is "AA' I am making the cell in the column airline id as readonly. In my example I am putting a check and readonly on the same column. However you can do this for different columns as well.
In order to achieve this you need to add a new context attribute 'READONLY' of type abap_bool to the context node which is bound to data node of ALV.
The method where I populate the node has the following code to populate the data.
data: lr_input_node type ref to if_wd_context_node,
lr_flight_node type ref to if_wd_context_node,
lv_cityfrom type s_from_cit,
lv_cityto type s_to_city,
ls_from type bapisfldst,
ls_to type bapisfldst,
lt_flights type table of bapisfldat,
ls_flights type bapisfldat.
data: lt_final type if_mainview=>elements_node_flighttab,
ls_final type if_mainview=>element_node_flighttab.
* Instantiate the variable lr_input_note to the node NODE_FLIGHT
lr_input_node = wd_context->get_child_node( name = 'NODE_FLIGHT' ).
* Instantiate the variable lr_flight_note to the node NODE_FLIGHTTAB
lr_flight_node = wd_context->get_child_node( name = 'NODE_FLIGHTTAB' )
* Get the attributes CityFrom und CityTo
lr_input_node->get_attribute( exporting name = 'CITYFROM'
importing value = lv_cityfrom ).
lr_input_node->get_attribute( exporting name = 'CITYTO'
importing value = lv_cityto ).
* Fill the stuctures ls_from and ls_to
ls_from-city = lv_cityfrom.
ls_to-city = lv_cityto.
* Call the function BAPI_FLIGHT_GETLIST
call function 'BAPI_FLIGHT_GETLIST'
exporting
destination_from = ls_from
destination_to = ls_to
tables
flight_list = lt_flights.
Now I am going to check if the airline id is 'AA' and based on that I will fill the readonly context attribute.
loop at lt_flights into ls_flights.
MOVE-CORRESPONDING ls_flights to ls_final.
if ls_flights-airlineid = 'AA'.
ls_final-readonly = abap_true.
else.
ls_final-readonly = abap_false.
endif.
append ls_final to lt_final.
endloop.
Finally bind the data to the context node.
* Bind the data to the node NODE_FLIGHTTAB
lr_flight_node->bind_elements( lt_final ).
Now you need to do the ALV configuration settings.
* create an instance of ALV component
DATA:
lr_salv_wd_table_usage TYPE REF TO if_wd_component_usage.
lr_salv_wd_table_usage = wd_this->wd_cpuse_alv( ).
IF lr_salv_wd_table_usage->has_active_component( ) IS INITIAL.
lr_salv_wd_table_usage->create_component( ).
ENDIF.
* get ALV component
DATA:
lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
lr_salv_wd_table = wd_this->wd_cpifc_alv( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
CALL METHOD wd_this->alv_config_table->if_salv_wd_table_settings~set_read_only
EXPORTING
VALUE = ABAP_FALSE
* set visible row count
DATA:
lr_table_settings TYPE REF TO if_salv_wd_table_settings.
lr_table_settings ?= wd_this->alv_config_table.
lr_table_settings->set_visible_row_count( '10' ).
DATA:
lr_column_settings TYPE REF TO if_salv_wd_column_settings,
lr_column TYPE REF TO cl_salv_wd_column.
lr_column_settings ?= wd_this->alv_config_table.
DATA: lr_input_field TYPE REF TO cl_salv_wd_uie_input_field.
lr_column = lr_column_settings->get_column( 'AIRLINEID' ).
CREATE OBJECT lr_input_field EXPORTING value_fieldname = 'AIRLINEID'.
lr_column->set_cell_editor( lr_input_field ).
lr_input_field->set_read_only_fieldname( value = 'READONLY' ).
CALL METHOD lr_column_settings->delete_column
EXPORTING
id = 'READONLY' -
Not able to color different rows with different colors in a column of table
Hi,
I am trying to to display different rows with different colors in a column of the table based on some decode condition.
I have gone through the following threads :
Can we colour the rows in the column of a table
Changing Color of a value in a column
This is what i have done :
1.Added the following code to custom.xss(changed the name to Custom.xss as suggested in one of the above threads) --- in path ---- jdev\myhtml\OA_HTML\cabo\styles
<style selector=".1">
<includeStyle name="DefaultFontFamily"/>
<property name="font-size">11pt</property>
<property name="font-weight">Bolder</property>
<property name="color">#008000</property>
<property name="text-indent">3px</property>
</style>
<style selector=".2">
<includeStyle name="DefaultFontFamily"/>
<property name="font-size">11pt</property>
<property name="font-weight">Bolder</property>
<property name="color">#FFFF00</property>
<property name="text-indent">3px</property>
</style>
2. Sql query of the VO is :
select comments,role ,decode(role,'REQUESTER','1','2') Colorattr from xxat_sars_action_history where request_id = :1 and event_name = :2 and action_code <> 'PENDING'
order by sequence_num desc
3. Coded the following in the process request of the controller:
OATableBean table = (OATableBean)webBean.findIndexedChildRecursive("CommentsTB");
OAMessageStyledTextBean roleBN = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("role");
OADataBoundValueViewObject cssjob = new OADataBoundValueViewObject(roleBN,"Colorattr");
roleBN.setAttributeValue(oracle.cabo.ui.UIConstants.STYLE_CLASS_ATTR, cssjob);
where 1 and 2 form the colors ( i have even tried with 'Red' and 'Yellow'...as it was not working replaced with 1 and 2)
4.The query returns data fine with corresponding 1 and 2 values.
But different colors are not getting reflecting on to the UI.
I am testing this on my local jdev.
Please do let me know if i am missing something.
Thanks ,
Sushma.Any Clues please.....
Thanks,
Sushma. -
thx guys.....i have a progress now in LV
But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
Attachments:
My Project.vi 31 KB
rumus motor bakar.xls 14 KBduplicate post
-
How to set different renderers to different cells in same column of JTable?
Hello Friends,
I need your help again...
Does any body knows, how to set different renderer's for different cells of same column in JTable..??
For ex.
Col1 Col2 Col3 Col4
A A A A
A A A B
A A A C
A A A D
Where A B C D would be different Renderers. I want set exactly same ,,, ie. one column with different renderer at different cell positions..
Right now i m setting renderer using statement bellow :
table.getColumnModel().getColumn(int).setCellRenderer(rederer_Instance);But with this, effect in the last renderer is applicable whole column....
Can any body help me out ?????????
please refer this thread for similar kind of discussion...
http://forums.sun.com/thread.jspa?forumID=57&threadID=571445Thanks
SuyogPlease refer to the first reply of [this thread|http://forums.sun.com/thread.jspa?forumID=57&threadID=571445] for the answer. If you have a specific problem implementing it, post you code with a specific question.
-
Passing Parameters For Same Columns In 2 Different Tables
OBIEE 11g
I have 2 different dimension tables in my Subject Area.
Dim1 has following columns: Promotion Code, Promotion Description, Promotion Date
Fact1 has following columns: a_count, b_count, c_count
Dim2 has following columns: Promotion Code, Promotion Description, Promotion Date
Fact2 has following columns: a_count, b_count, c_count, d_count
Report 1 has following columns: Promotion Code, Promotion Description, Promotion Date, a_count, b_count, c_count (From Dim1 & Fact1)
Report 2 has following columns: Promotion Code, Promotion Description, Promotion Date, a_count, b_count, c_count, d_count (From Dim2 & Fact2)
I have tried to pass the parameters Promotion Code, Promotion Description, Promotion Date from Report 1 to Report 2 but this has not worked for me as Report 2 is not receiving the parameters. Is there a way I can do this. Thanks in advance.Thanks for your response Jay,
In Report 1 I have added prompts (Prompts tab) for Promotion Code, Promotion Description and Promotion Date. I have also set the following presentation variables in the prompts:
PromotionCode,
PromotionDescription
PromotionDate
In Report 2 I then add a filter for each of the same columns and match them to the presentation variables created in Report 1 as follows:
Promotion Code is equal to / is in @{PromotionCode}
Promotion Description is equal to / is in @{PromotionDescription}
Promotion Date is equal to / is in @{PromotionDate}
My expectation is that the values in the presentation variables will be passed from the Prompts in Report 1 to the filters in Report 2. This is not what is happening. Im not sure what I am doing wrong. -
Constructing Calculated Measures in MDX for different measures using same columns in a fact table
Hello,
i have a fact table with 2 columns corresponding to dimensions Dim1, Dim2. In the same table i have 4 other columns Value_Type(int), INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string). There are a number of measures which are identified by Value_Type and
depending on their nature could be written in one of the 3 columns (INT_VALUE(int), FLOAT_VALUE(float), TEXT_VALUE(string)) Let's say Measure1 with Measure_Type=1 is age, 2 is account balance and 3 is Name for clarity. There could be other measure types that
use these 3 same columns for data. So the sample fact table looks like this
Dim1 Dim2 Measure_Type INT_VALUE FLOAT_VALUE TEXT_VALUE
10 10 1 25
10 10 2 2000,34
10 10 3 John
10 20 1 28
10 20 2 3490,23
10 20 3 Frank
My task is to write an MDX query for each Dim1, Dim2 combination which returns all 3 measures in the same row. The idea is to construct a calculated member for each Measure that returns value from the right field. For example for Measure1 we take INT_VALUE
with measure_type=1. The problem is i don't know how to construct MDX query for these calculated members. Can you please help me?
So my final goal is to write an MDX query that returns all measures in one row for each set of Dim1, Dim2
SELECT [Measure1], [Measure2], [Measure3] ON COLUMNS,
NON EMPTY [Dim1].[Dim1].[Dim1].Members*[Dim2].[Dim2].[Dim2].Members ON ROWS
FROM [Cube]
Dim1 Dim2 Measure1 Measure2 Measure3
10 10 25 2000,34 John
10 20 28 3490,23 FrankHi Kosmipt,
I would combine the "INT_VALUE", "FLOAT_VALUE" and "TEXT_VALUE" columns into one with STRING data type for the fact table. And there should be one dimension to store the Measure_Type informations. Then in cube, you can write MDX scope for every one of
"Measure_Type" dimension members. For example,
scope(
[Measures].[M]
[DimMType].[MType].&[1]= CINT([Measures].[M]);
end scope;
Once the cube is built by the above way, you can write MDX like something like the following to achieve your purpose.
WITH member [Measures].[Measure1] AS ([DimMType].[MType].&[1],[Measures].[M])
member [Measures].[Measure2] AS ([DimMType].[MType].&[2],[Measures].[M])
member [Measures].[Measure3] AS ([DimMType].[MType].&[3],[Measures].[M])
thanks,
Jerry -
Same column name from different table
i have a sql query as like this : "SELECT * FROM TABLE1,TABLE2". i use oracle. both TABLE1 and TABLE2 have the same column named 'COLUMN1'. while i get rows how i know the value of COLUMN1 from which table (TABLE1 or TABLE2).
sample code snippet is above. do u help me!
while (rs.next())
value1 = rs.getString("COLUMN1");
// is value1's value from table1 or table2. how do i know this?
// i try value1 = rs.getString("TABLE1.COLUMN1"); but it doesn't work :(
....I case you don't know what an alias is, it would look something like this:
SELECT a.COLUMN1 as FirstColumn1, b.COLUMN1 as SecondColumn1 FROM FirstTable a, SecondTable b
Notice that in the FROM clause we've appended a short name for each table. You're not limited to one character, but I try to keep it simple. Now we can refer to the tables as a and b.
Because I did that I have to refer to any ambiguous columns (although it's good practice to refer to ALL columns) using the table name prefix and a period. This tells the driver which "COLUMN1" I want. Then we include as AS clause which allows us to tell the driver what we want that column name to be when it's returned to us. This is specially usefule when I have two columns in two separate tables with the same name (as you have here) or if I'm calculating data (i.e. (a.QTY * b.PRICE) as UnitPrice) that doesn't have a column name, so here I can give it one.
It's a little weird at first since you use the alias names in the select before you actually define them in the FROM clause, but you'll get use to it.
Now you retrieve FirstColumn1 and SecondColumn1 from your ResultSet, not Column1.
HTH. -
I am having trouble getting a numbers spreadsheet to hold different formats in the same column. A column with a date formatted heading will not convert to $ for the cells below. Any suggestions would help.
Hi Wayne,
Thank you for this response. I have tried this but when I start enterring $ amounts some, such as $6.00, go in OK others such as $4.00 appear as a date ie 4 Oct 12.
Kind regards
Paul -
Different ItemRenderer's in the same column of a datagrid
I am using actionscript to read some XML input and dynamically add data into the datagrid.
Currently I am reading the first row and depending on the data type of the coulmn i am creating the column to be a IntemRenderer of Image, or Link button.
Now is there anyway of adding some rows to be LinkButton ItemRenderes and some to be Image ItemRenderers, in the same column?
Any examples are also appreciatedYou can try overriding createColumnItemRenderer
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
SUM two fileds from different rows from the same table
I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
E.g.
BillingTransactionsIndex CreateDate UserType UserIndex TransType Reference Total Balance
2 6/5/2008 15:02 1 51 1 150 -288.2 -288.2
5 6/8/2008 11:55 1 51 1 157 -1.58674 -289.787
In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
Please help
ThanksSQL> with tbl as
2 (select 1 as ID, 90 as total from dual
3 union all
4 select 2 as ID, 23 as total from dual
5 union all
6 select 3 as ID, 15 as total from dual
7 union all
8 select 4 as ID, 20 as total from dual)
9 select id , total, sum(total) over (order by ID) as balance from tbl
10 /
ID TOTAL BALANCE
1 90 90
2 23 113
3 15 128
4 20 148
SQL>
Maybe you are looking for
-
REg: Issue Automatic PO creation
Hello Gurus while converting the PR to PO using me59 i'm getting an error "PO not created due to item error Enter a quantity" In PR i have maintained the quantity as 0.5. but even then it is not fetching the quanity How to rectify this error Kindly g
-
B2 Error with new MSI GTX 970 :(
Hi there team! Just registered to try and get help. I spent around 6 hours researching + trying all the suggestions throughout many different forums, but the B2 error still persists. I am currently running the following spec: Mobo - MSI Z68A-G43 (G3)
-
Create blocked purchase order with BAPI_PO_CREATE1
Hi, I´m creating stock transport orders with BAPI_PO_CREATE1. At first, I need to set them to the release status 'S' for blocked. After some checks, I want be able to relase it and create the delivery. I have found some fields like rel_status inside
-
Is this yellow "other" portion potentially destructive to one's iPhone? Is there anyway to "clean-up" your iphone?
-
Can't select text on a safari search results page
Hi, I'm using an Ipad 3 I have safari sset to use the google search in settings but when I search for something and it shows the results page I can only select links holding my finger on the text below the link does nothing. sometimes the answer i'm