How to return the same SUM value from two tables
Hello,
I have the following data:
SQL> SELECT * FROM t1;
T1_ID T1_VALUE
1 500
1 500
SQL> SELECT * FROM t2;
T2_ID T2_VALUE
1 1000
SQL> SELECT t1_id, SUM(t1_value), SUM(t2_value)
2 FROM t1, t2
3 WHERE t1_id = t2_id
4 GROUP BY t1_id;
T1_ID SUM(T1_VALUE) SUM(T2_VALUE)
1 1000 2000How is it possible that SUM(T2_VALUE) returns also 1000.
Thank you
Here's one way:
with t1 as (select 1 t1_id, 500 t1_value from dual union all
select 1 t1_id, 500 t1_value from dual),
t2 as (select 1 t2_id, 1000 t2_value from dual)
select t3.t3_id, t3.t3_sum, t4.t4_sum
from (select t1_id t3_id, sum(t1_value) t3_sum from t1
group by t1_id) t3,
(select t2_id t4_id, sum(t2_value) t4_sum from t2
group by t2_id) t4
where t3.t3_id = t4.t4_id
Similar Messages
-
How to share the same coherence cache in two EPN
hi,all:
I need to share the same coherence cache in two EPN. to put data into this coherence cache.
only whe EPN can been deploy ok, the other EPN deploy will get below exception.
Caused By: java.lang.IllegalStateException: Service "synergy-scheme-service" has been started by the factory with a different configuration descriptor
at com.tangosol.net.DefaultConfigurableCacheFactory.validateBackingMapManager(DefaultConfigurableCacheFactory.java:1246)
who can tell me why? or who can give me a example on how to share the same coherence cache in two EPN.
thanks a lotsHi,
This is because the system detects that you are using different configuration for the cache of the same name(and the domain name). If you want, we can discuss it, my mail is [email protected]
Thanks
Junger -
Need of SQL query in selecting distinct values from two tables
hi,
I need a query for selecting distinct values from two tables with one condition.
for eg:
there are two tables a & b.
in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
can anybody please help me.
Thanks in advance,
RatheeshNot sure what you mean either, but perhaps this will start a dialog:
SELECT DISTINCT a.empno,
a.name,
a.sex,
b.salary,
b.doj
FROM a,
b
WHERE a.empno = b.empno;Greg -
How to Print the same field value in a single row
Hi,
I need to print the same field values in a single row
For Examble
in a table TestTable
ID Name Value
1 AB 120
1 BC 150
1 CD 130
2 AB 111
2 BC 112
2 CD 113
I need the query like if the Name contains BC and CD then i need to print like ID, BC Value, CD Value as below
ID BC'Value CD'Value
1 150 130
2 112 113
Kindly suggest me...
Thanks in Advance
AnuHi,
Since you're on 9i some available functionality unfortunatly isn't at your disposal.
This should work, however, using your sample data:
MHO%xe> create table t as ( -- generating sample data:
2 select 1 cid, 'AB' cname, 120 cvalue from dual union all
3 select 1, 'BC', 150 from dual union all
4 select 1, 'CD', 130 from dual union all
5 select 2, 'AB', 111 from dual union all
6 select 2, 'BC', 112 from dual union all
7 select 2, 'CD', 113 from dual
8 );
Tabel is aangemaakt.
MHO%xe> select cid
2 , max(decode(cname, 'BC', cvalue, null)) BC_value
3 , max(decode(cname, 'CD', cvalue, null)) CD_value
4 from t
5 group by cid;
CID BC_VALUE CD_VALUE
1 150 130
2 112 113For reference and future challenges, see:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:419593546543
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
How to link the same horizontal page for two different vertical pages without duplicate them?
Hey guys,
Is there a way to link the same horizontal page on two different vertical pages without duplicate the horizontal page?
I have a doublepage of a book splitted in two parts in different vertical pages but i want link the fullsized image in the horizontal page for both of them. Got that? hahaha
Thank you allConfusing But interesing.
I think it's possible. I have a idea. It will need one advanced trick.
To explain it, I need test simply haha. -
How to return more than one value from a function
hello everybody,
Can anyone tell me how to return more than a single value from a function, the problem is i have 4 points,
2 points form one line ,another 2 points form 2nd line ,each point is 3 dimensional(x,y,z coorinates) so i will pass these values to func(x1,y1,z1,x2,y2,z2,x3,y3,z3,x4,y4,z4), i will find the point of intersecton of two lines and i will get it as x,y,z , now how to return these 3 coordinates,usually the function returns only one value, please help me to solve it out.
Thanks.I think the easiest way or trick here is (easiest isn't always the best as we know, but atleast this one will work) to create simple data array. and pass that. Create an array with:
<code>
class justArray {
int x=0
int y=0;
int z= 0;
...somewhere
justArray[] points= new justArray[4];
points[0].x= ..
points[0].y= ..
points[0].z= ..
points[1].x= ..
return points[]
</code> -
How to retrieve the data/property value from portalapp.xml
Hi I would like to retrive the some common data from the portalapp.xml file
<application>
<application-config>
<property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
</application-config>
<components>
<component name="DynZMMGR">
<component-config>
<property name="ClassName" value="DynZMMGR"/>
<property name="SecurityZone" value="DynZMMGR/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMMGR.jsp"/>
</component-config>
<component-profile/>
</component>
<component name="dynpagedel">
<component-config>
<property name="ClassName" value="dynpagedel"/>
</component-config>
<component-profile/>
</component>
<component name="VARIANTLIST">
<component-config>
<property name="ClassName" value="com.sap.ep.r3rpts.VARIANTLIST"/>
<property name="SecurityZone" value="com.sap.ep.r3rpts.VARIANTLIST/high_safety"/>
</component-config>
<component-profile/>
</component>
<component name="DynZMM33">
<component-config>
<property name="ClassName" value="DynZMM33"/>
<property name="SecurityZone" value="DynZMM33/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMM33.jsp"/>
</component-config>
<component-profile/>
</component>
</components>
<services/>
</application>
The above is my portalapp.xml file .
I want to retrieve the common data across the component.
These datas are common across the components .
I kmow by putting the data inside the
component name="DynZMM33">
<component-config>
<property name="ClassName" value="DynZMM33"/>
<property name="SecurityZone" value="DynZMM33/high_safety"/>
<property name="ComponentType" value="jspnative"/>
<property name="JSP" value="pagelet/DynJspZMM33.jsp"/>
</component-config>
<component-profile>
<property name="UserID" value="userid"/>
<property name="password" value="password"/>
</component-profile>
</component>
this becoms component specific ... which I can retriev the by using
String ClientVal = request.getComponentContext().getProfile().getProperty("Client");
in doContent() method ..
But this way i have to specify these properties in all the component.. which is repetetive in nature.
I would rather put it in common location and want to retrieve the info from the portalapp.xml...
How to achieve this
I am using "AbstractPortalComponent" .
thanks
pkiranHi Prashanth,
see Reading another iView's profile personalized values and Validate PCD URI
Anyhow, maybe you should implement a service which returns the values (from the service profile). This would be more clean for accessing global values.
Hope it helps
Detlev -
How to calculate the total sum value of a particular field that repeats
Hi All,
I have the following Req...File----Idoc Scenario
In the Inbound xml file i will get the Sales Order details with suppose 10 line items( 10 Orders)
Each line item represents one one SO. So totally i wil have 10 Sales Orders in this file.
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_Sales_Order xmlns:ns0="http://sap/Sales_Order">
<Header>
<COMP_CODE></COMP_CODE>
<DOC_TYPE></DOC_TYPE>
<SUPPL_VEND></SUPPL_VEND>
</Header>
<Item>
<ITEM></ITEM>
<MATERIAL></MATERIAL>
<PLANT></PLANT>
<QUANTITY></QUANTITY>
<Amount></Amount>
</Item>
In the above structure Item Segment will repeats as many no. of Sales Orders comes in a file.
In a file if there are 10 Orders means the Item segment wil repeats 10 times.
I have the Amount field in the Item Segment, each and every time that needs to be added to next Amount value that presents in the next Line Item.
Finally i will have the Another separate field caled Grand Total, and i have to get the total summation of the 10 values of the Amount field at last.
Can we achieve this using UDF or is there any way to do this
REgardsHi,
Do like this, actually in your case sum is taking place before the condition check for discount type
do a little change in mapping
DiscntType--removeContext--
EqulsS-------IfWithoutElse----Amount---removecontext--then---SUM-
Connstatnt(Value)
--->GrandAmount
Krishna, Check the same question asked by Rajesh in thread Calculate totals of segments that occur multiple times
Thanks! -
How to use the same column value in the casecadeing parameter in ssrs report?
Hi frnz,
I have a table site contains one filed SiteCode
Now i have fields like below using the below quries
SThe above are the two results sets coming from the single table ,now i will use these two results /Query in my ssrs Casecade report
1.First result set/Query will use for the first dataset and use these values in the paramet1 selection as PrimaryCodes
2.Second result set/Query will use for the second Dataset and use these values in the parameter2 as SecondayCodes
3.Using these two datsets and create a Casecadeing paramet in ssrs report.
4.so using this information how can i create the Casecade report ,I have tried different ways but i didnt get the soluction
I have done the follw but ididnt get the o/p.
I have created two parameter and mapped to the results but while paramter selection i will able to see only the first paramet(PrimaryCodes) ,and i will not see the second paramter(SecondaryCodes) it could not show me the second paramter values in the drop
down list.
Note:Here i will use the Single Table to get the all the sitecodes
Can some one please help me out for this report.
Thanks.Hi,
Try below links for your reference:
http://blogs.msdn.com/b/sqlforum/archive/2011/05/26/ssrs-cascading-parameter-with-optional-select-all-in-sql-reporting-services-report.aspx
http://msdn.microsoft.com/en-us/library/dd255197.aspx
http://blogs.msdn.com/b/psssql/archive/2010/01/29/how-to-have-a-select-all-multi-value-cascading-parameter.aspx
sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **. -
How to pass the check box values from one view to another view
Hi Experts,
I have a selection screen view which consists of check boxes.
WBS System status.
Release Completed Closed as 3 check boxes.
Note : The above ones are check boxes.
Based on the selection made by the user, those values needs to be passed to second view which retrieves the data and
displays the data accordingly.
At the same time if the user does not make any selection, then WBS System status should contain Released, Completed and Closed values and that needs to be sent to Second view.
Kindly advise.
Regards,
Chitrasenhi ,
make a attribute of type WDY_BOOLEAN to achieve this functionality
u need to follow these steps :
1 in side ur component controller , under the ATTRIBUTES tab , make 3 attributes say attr1 , attr2 and attr3 of type WDY_BOOLEAN
2 create a context node , cn_check and 3 context attribute ca_check1 , ca_check2 and ca_check3 in ur first view for
release , complete and close check boxes
3 inside the DOINIT of ur 1st view , set the attributes attr1 , attr2 and attr3 to blank
wd_comp_controller->attr1 = ' '
wd_comp_controller->attr2 = ' '
wd_comp_controller->attr3 = ' '
4 inside the method , where u r validating , if the check boxes are checked or not , read the attributes ca_check1 , ca_check2 and
ca_check3
DATA lo_nd_cn_check TYPE REF TO if_wd_context_node.
DATA lo_el_cn_check TYPE REF TO if_wd_context_element.
DATA ls_cn_check TYPE wd_this->element_cn_check.
DATA lv_ca_check1 LIKE ls_cn_check-ca_check1.
* navigate from <CONTEXT> to <CN_CHECK> via lead selection
lo_nd_cn_check = wd_context->get_child_node( name = wd_this->wdctx_cn_check ).
* get element via lead selection
lo_el_cn_check = lo_nd_cn_check->get_element( ).
* get single attribute
lo_el_cn_check->get_attribute(
EXPORTING
name = `CA_CHECK`
IMPORTING
value = lv_ca_check1 ).
IF lv_ca_check1 EQ 'X' .
wd_comp_controller->attr1 = ' X'
wd_comp_controller->attr2 = 'X '
wd_comp_controller->attr3 = ' X' -
How to return the week number starting from Sunday as the first day
Hi Friends,
My application needs to have a report for the weekly totals and must have the Sunday as the first day for the week. For example, January of 2005 should be in the report for having six weeks, Jan 1 is Saturday, this is week 1, Week 2 is from 2 to 8, and the last week , week 6 has 30 and 31. Days need not be displayed, only the week number as follows:
Week Number Total Sales
=========== =========
Week 1 8,525
Week 2 8,168
Week 3
Week 4
Week 5
Week 6
The discoverer hierarchies function for week (eul_date_trunc(item_date, '"W"W')) seems to start the week from the first day of the month regardless of the day. Oracle function TO_CHAR(item_date, 'W') does the same thing, .As the result, the January of 2005 has only 5 weeks.
Any help or advice for this issue will be greatly appreciated.
Thank you very much,
J.KTry this
---------------------------------------------actual formula---------------
select ceil(
( to_number(to_char(to_date('1-'||to_char(sysdate,'MON-YYYY'),'DD-MON-YYYY'),'D')) -1
+ to_number(to_char(sysdate,'DD'))
) / 7
week_number
from dual
e.g try different dates below by replacing 31-Jan-2005
select ceil(
( to_number(to_char(to_date('1-'||to_char(to_date('31-JAN-2005'),'MON-YYYY'),'DD-MON-YYYY'),'D') ) -1
+ to_number(to_char(to_date('31-JAN-2005'),'DD'))
) / 7
week_number
from dual
How does it work
week number is calculated by dividing the current day number by number of days
so in your case if the week starts at a different day , you just add the offset and divide by 7
In the first part, i am finding the week day number for the 1st day of the current month and this is used as offset.
Hope this helps
-nj
http://www.infocaptor.com -
How to use the same variable value for data entry and the planning sequence
Hi,
the scenario is the following:
Using the WAD template a user enters cost center plan data. The cost center is selected by the chosen value for the variable "V1".
Afterwards he shall push a button which starts a planning sequence (including saving the data and further functions). This planning sequence uses a filter that also contains the variable "V1".
What or where has it to be defined that the planning sequence uses automatically the same value for the variable "V1" as selected for the data entry?You have to define in the planning function. The planning sequence is only a sequence and it read the planning functions underneath it.
Ravi Thothadri -
Exchange Rate: Routine to copy the "Exchange Rate" value From TCURR table
Dear experts,
I have created a cutomised Key Figure (ZEXCHRATE) with the 0currency as the unit and this field is included in my ZCOPA_C21 Infocube.
In the update rule, it was then appointed with a simple routine below;
(PROGRAM UPDATE_ROUTINE.
$$ begin of global - insert your declaration only below this line -
TABLES: TCURR.
DATA: IT_TCURT Type TCURR occurs 0 with header line.
$$ end of global - insert your declaration only before this line -
FORM compute_data_field
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
USING COMM_STRUCTURE LIKE /BIC/CSZCOPA_TPL_IS
RECORD_NO LIKE SY-TABIX
RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING RESULT LIKE /BIC/VZCOPA_C21T-/BIC/ZEXCHRATE
RETURNCODE LIKE SY-SUBRC
ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal table "MONITOR", to make monitor entries
SELECT * FROM TCURR appending corresponding fields of table
IT_TCURT
WHERE KURST = 'M'
AND FCURR = 'USD'
AND TCURR = 'IDR'.
AND GDATU = ___.
AND UKURS = ___.
Sort IT_TCURT by GDATU descending.
Loop at IT_TCURT.
Move IT_TCURT-UKURS to RESULT.
Exit.
Endloop.
result value of the routine
RESULT = space.
if the returncode is not equal zero, the result will not be updated
RETURNCODE = 0.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine)
Which will basically copy all the contents of TCURR into an internal table (IT_TCURT), sort it and then only copy out the UKURS (Exchange rate) data into the customised ZEXCHRATE to get the latest exchange rate value.
Routine was checked and its fine.
The problem is, upon checking the update rule, it returned an error message;
"No Unit maintain for Key Figure Exchange Rate Local".
Double checked the declaration of ZEXCHRATE, the unit was there.
My questions;
1. Is this the correct way of doing it ? I just want to be able to show the exchange rate value in my query (hence the existence of ZEXCHRATE).
2. Is there an alternative way of achieving the same result ?
Your help or advice will be greatly appreciated.
Thanks
KGHi Sreeni,
Referring to the " but the conversion from VEF to USD is happening at a rate @0.23256 which is valid till 02/13/2013 only" part in your post, the date given in OB08 for currency rate is valid from and not valid till. Hence, please check the setting once. Once you enter the rate from 02/13/2013, the rate is valid till you enter another date later than 02/13/2013.
Regards, -
Is it possible to work on the same files/catalog from two different computers?
My wife and I are photographers and work on two separate iMacs. We just purchased an NAS and would like to know if we can both access the same files AND the Lightroom catalog from our respective computers. All of the files are on the NAS but I can't figure out how to get her computer to recognize the catalog. Any help would be greatly appreciated!
-BrentAnother option, since you already have the nas, is to get something like "Synchronize! Pro X",and use the nas to transfer the catalog back and forth. You don't have to USB the catalog, just transfer it to the nas each time you are done, and before you start...
Of course, I think both solutions are based on you not editing at the same time... i.e., both of you are making changes, as neither approach will work for that!
Cheers! -
How to use the same apple id on two different iphones with different sync?
Hi all,
I own an iPhone 4s for personal use. Soon my company is going to give me a business phone and I can choose to have another iPhone. I'd love it but I don't know if what I wanna do is possible.
Let's say I will have iPhone P (personal) and iPhone B (business) and Apple ID MyID.
At the moment on iPhone P with account MyID I have application App1, App2, ... App9, I have contacts Cont1, Cont2, ...Cont9, I have songs Song1, Song2, ... Song9. All these are synced on my personal PC via iTunes and stored in the iCloud.
When I'll get iPhone B I'd love to be able to use on it my Apple ID MyID and to sync it with my business PC (so NOT the same one I use for iPhone P).
The configuration I'd love to have would be the following.
iPhone P
- Applications: App1, App2, App3, App8, App9
- Contacts: Cont1, Cont2, ... Cont9
- Songs: Song1, Song2, ... Song9
iPhone B
- Applications: App4, App5,App6, App7, App8, App9, App10 etc.
- Contacts: Cont1, Cont2, Cont10, Cont11, ..., Cont20
- Songs: Song1, Song2, Song10, Song11, ... Song20
So will it be possible using the same Apple ID MyID on both iPhones to have this configuration? Some apps, contacts and songs in common and some differents?
If so, how should I configure the two iPhones and the two PCs?
Kind regards.If you use the same Apple ID for iCloud on each device, yes. However, you can use the same Apple ID for iTunes content on each device, but different Apple ID's for iCloud, iMessage, FaceTime, etc., on each device. That way, you can have whatever iTunes content you want on each phone, but keep all of the other data separate. You can create another Apple ID here:
https://appleid.apple.com/cgi-bin/WebObjects/MyAppleId.woa/wa/createAppleId?loca lang=en_US
Must be a verified email address.
Maybe you are looking for
-
Error while Importing XSD in to XI system
Dear All I'm trying to import XSD's in to my XI system & received the following error. Can some one give me a insight in to this error. javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoSuchMethodError:
-
Java related processes are not comingup
Hi, We have copied our current kernel into a new library and had switched to new kernel library. There after, the processes, DISPATCHER, SERVER0, SDM AND JCONTROL are not coming up. Remaining all processes are normal. Afterwards, we had revert back t
-
Exporting widescreen anamorphic video for the web
I have a project in fce which is filmed in widescreen anamorphic at 720, 576 the setup in fce is dv-pal anamorphic and anamorphic is checked in item properties. When I export using quicktime using h.264 encoder it shows at as widescreen in the previe
-
(x86) Inline assembler syntax errors for 8bit variables
Hello, I am porting some gcc code to Solaris and have some issues with the inline assembler. It works reasonably well on most of my code but with some instructions I have difficulties. In gcc, when I declare a variable as char/unsigned char and refer
-
Creating Compalint in CRM 7.0 IC WebClient
Hello Experts, We are implementing CRM 7.0 Service. Interaction center is one of the components. We are creating Compalint in Interaction Center, a follow-up document e.g. a Service Order needs to be created. We are facing an issue, that Items are no