How to get the sum of "(qty*rate) as salesValue 'as TotalSalesValue cust_id agenda?"
Mr President.
I have to take the column values from3, or 4 tables and two of them need to be multiplied, then get the sum of this value multiplied by using Group by and order clause.
as below
cust_id | prod name | Qty. | rate | value | totalValue |
---|---|---|---|---|---|
01 | one | 01 | 500 | 500 | |
01 | b | 02 | 400 | 800 | 1300 |
How to get there
Select
cstmr.cust_id CustId,
PRDT. Name AutoCAD,
SL.sal_qty SalQty,
SL.unit_sal_price UnitSalPrice,
SL.sal_qty * SL.unit_sal_price as SalVal,
Sum(SL.sal_qty*SL.unit_sal_price) as TotalSalesValue
Of
cstmr customer,
salesLine sl,
prdt product
where
PRDT.prod_id = sl.prod_id
Group
cstmr.cust_id,
PRDT. Name,
SL.sal_qty,
SL.unit_sal_price
order by
cstmr.cust_id
Concerning
Your expected results include values that are not in your input data - there is no M.BOARD product, for example. This is an adaptation of Manik code that will give you the subtotals for each customer:
SELECT client_name c.nom,
product_name p.Name,
SL.sal_qty,
SL.unit_sal_price,
SL.sal_qty * SL.unit_sal_price AS salesvalue,
CASE
WHEN ROW_NUMBER () OVER (partition by order of c.cust_id p.prod_id desc, sl.sal_id desc) = 1 THEN
SUM (sl.sal_qty * sl.unit_sal_price) OVER (PARTITION BY c.cust_id)
END totals
FROM customer c INNER JOIN sales s ON s.cust_id = c.cust_id
INNER JOIN salesline sl ON sl.sal_id = s.sal_id
INNER JOIN product p ON p.prod_id = sl.prod_id
ORDER BY c.cust_id, p.prod_id, sl.sal_id
You could get the grand total of lines by the Union in a second query, or by doing something smart using ROLLUP. But I leave that to you because I think you should at least do some of your own homework.
Tags: Database
Similar Questions
-
How to get the sum of the first row in the previous row?
Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line. Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?Hello
kamranpathan wrote:
Dear gurus... I need to get the sum of a column of the first row of my result set to the previous line based on a condition. I read analytical functions for this but they provide the sum of the first rank to Current Row through declaration "rows between Unbounded preceding and current line.If you do not explicitly give a windowing clause, then you get the default windowing clause you indicated.
If you want another clause of windowing, ionclude in the analytic function call.Y at - it a statement that calculates the sum as "rows between Unbounded preceding and previous row?
Yes. The correct syntax for "Previous rank" is «PREVIOUS 1»
... ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
For more information, search for "Analytic Functions" in the manual of the SQL language:
http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions004.htm#sthref917I hope that answers your question.
If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all tables and also post the results desired from these data.
Explain, using specific examples, how you get these results from these data.
Always tell what version of Oracle you are using.
You will find the answers better faster if you always provide this information whenever you post a question.Published by: Frank Kulash, Sep 17, 2011 17:04
I just saw Etbin responses.
As usual, Etbin has a good point. If the column that you are basically cannot be NULL, then it is probably easier to subtract the total current line and use the default windowing clause.
Even if it can be null, you find may be easier to use this approach. -
How to get the sum by customer?
Hi, in this query below, I want all the s () basically summing up of each "INVESTOR_CODE", can anyone help please?
select b.INVESTOR_CODE , a.INVESTOR_NAME , b.DEPARTMENT_CODE , b.INVOICE_NO , b.INVOICE_TYPE , trunc(b.INVOICE_date) INVOICE_date, c.COMPANY_SHORT_NAME , sum(INVOICE_COMMISSION) INVOICE_COMMISSION, sum(INVOICE_KEEPING) INVOICE_KEEPING , sum(INVOICE_STAMP) INVOICE_STAMP, sum(INVOICE_OTHER) INVOICE_OTHER, sum(INVOICE_MISR) INVOICE_MISR, sum(INVOICE_INSURANCE) INVOICE_INSURANCE, sum(INVOICE_HAIAH)INVOICE_HAIAH from investor a , invoice b , company c , DEPARTMENT d where a.INVESTOR_CODE = b.INVESTOR_CODE and b.COMPANY_CODE = c.COMPANY_CODE and b.DEPARTMENT_CODE = d.DEPARTMENT_CODE and trunc(invoice_date) >= '14-AUG-07' exists(select 1 from OPERATION_LINE_SMAEDAY ols where ols.INVOICE_NO = b.INVOICE_NO and ols.INVOICE_type = b.INVOICE_type ) group by b.INVESTOR_CODE , a.INVESTOR_NAME , b.DEPARTMENT_CODE , b.INVOICE_NO , b.INVOICE_TYPE , trunc(b.INVOICE_date) , b.INVOICE_TYPE,c.COMPANY_SHORT_NAME order by b.INVESTOR_CODE , INVOICE_date;
For this table, the following query will do the grouping and order it as you want. You will still combine it with the previous query using the original paintings.
SQL> select investor_code 2 , investor_name 3 , department_code 4 , invoice_no 5 , invoice_type 6 , invoice_date 7 , company_short_name 8 , sum(invoice_commission) 9 , sum(invoice_keeping) 10 , sum(invoice_stamp) 11 , sum(invoice_other) 12 , sum(invoice_misr) 13 , sum(invoice_insurance) 14 , sum(invoice_haiah) 15 from samedaydata 16 group by investor_code 17 , investor_name 18 , rollup 19 ( ( department_code 20 , invoice_no 21 , invoice_type 22 , invoice_date 23 , company_short_name 24 ) 25 ) 26 order by investor_code 27 , department_code 28 , invoice_no 29 / INVESTOR_CODE INVESTOR_NAME DEPARTMENT_CODE INVOICE_NO INVOIC INVOICE_DATE COMPANY_SHORT_NAME SUM(INVOICE_COMMISSION) ------------- --------------- --------------- ---------- ------ ------------------- -------------------- ----------------------- SUM(INVOICE_KEEPING) SUM(INVOICE_STAMP) SUM(INVOICE_OTHER) SUM(INVOICE_MISR) SUM(INVOICE_INSURANCE) SUM(INVOICE_HAIAH) -------------------- ------------------ ------------------ ----------------- ---------------------- ------------------ 240007 john 2 123 sell 23-04-2010 00:00:00 OTC 27.5 3.4 6 4 0 2 10 240007 john 2 124 buy 22-04-2010 00:00:00 ORACLE 29.6 2.4 6 4 0 2 10 240007 john 2 125 sell 01-01-2010 00:00:00 ORACLE 63.5 2.4 6 4 7 2 10 240007 john 120.6 8.2 18 12 7 6 30 240008 paul 3 256 sell 19-12-2010 00:00:00 OTC 93.5 8.4 6 4 0 2 10 240008 paul 3 266 buy 06-03-2010 00:00:00 CBANK 83.2 3.4 6 3 0 2 9 240008 paul 3 322 buy 23-04-2010 00:00:00 CBANK 43.4 2.4 3 4 0 2 3 240008 paul 3 423 sell 23-04-2010 00:00:00 OTT 24.5 2.4 2 4 0 8 10 240008 paul 244.6 16.6 17 15 0 14 32 9 rows selected.
Kind regards
Rob. -
I have a photography teacher program Adobe and must add Adobe Illustrator for the BSc SAID curriculum I am on at the Academy of digital skills in Dublin, Ireland how I get the student discount to add Illustrator to mentoring rate?
I don't know if we can add a program, or you if have to go to a subscription 'all' education
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">===>
Don't forget to stay signed with your Adobe ID before accessing the link below
Creative cloud support (all creative cloud customer service problems)
-
How to get the timestamp of data DAQmx Read
Hello
I have to read 4 analog channels using DAQmx AI read in LabVIEW 2012. I am using screws DAQmx.
Acquisition rate is 4000 samples per second, and the number of samples per channel is 200.
I use only one task DAQmx to read the data. I get 4 data tables for 4 channels each table length is 200, every time, DAQmx Read happens.
But I want to get the seal of these 200 samples per channel. How to get the seal of these samples, made me know.
Thank you
You have not indicated your code. If you choose to read the waveform data, the cluster includes t0 and dt. That's all the information you need.
-
How to get the balance of an element value
Hello
I have a requirement to obtain related information with balance. I am able to read the information on the element except balance.how to get the value of the particular item balance.
for the application-> transfer and process-> queries with trust-> value the month selected and chosen balances button and queries with the obtained item name break it down the value of the balance.
These values I want in my query.i tried backend with calling package by passing parameters like the number of transfer, balance the id and date but iam getting value "0".
IAM new to hrms, Please help me on how to get this balance of values
Thank you
Hello
It is not very clear what you want to display in the form of balance for a given range of dates.
It depends on how you have configured your balances and periods and balance which you are referring.
The API allows for a given only date that matches the date earned.
Say, for example, that you have a "basic salary" defined with a "Treatment period assignment to Date" dimension and feed of the element that corresponds to the base salary.
"If you need get the 'wage base Total' (balance?) for the period February 1, 2015 ' to March 31, 2015", then you need get dates earned for payroll passes made during that period and call the package above with the appropriate settings.
Another way is by querying the tables/views directly: you can use, for example - it's perhaps easier to your situation:
Select sum (nvl (pbv.value, 0))
of pay_balance_values_v the VB.
where pbv.balance_name = 'base salary.
and pbv.database_item_suffix = '_ASG_PTD. '
and pbv.assignment_id =
and pbv.effective_date between to_date (' 01/02/2015 ',' dd/mm/yyyy')
and to_date (' 31/03/2015 ',' dd/mm/yyyy');
Kind regards
Rajen -
try to get the SUM of all of the charges with the having clause
Hi Oracle users.
I'm trying to accomplish to get a sum of a series of charges and it should be easy, but I can't get it.
For example, I have the following.
Select ACCTLOC, count(ACCTLOC) AS TOTALP FROM BOX_ACCTS_TBL WHERE TIME_REQ > SYSDATE-120 Group By ACCTLOC having (count(ACCTLOC) > 1) the results are ACCTLOC TOTALP Philly 15970 NY 8623 Tacoma 3 SanFran 195 Hartford 5 Miami 4374
How can I get the SUM of this group? Do I put this in PL SQL and do a procedure to carry out the selection? Is this the way to go on this?
I appreciate all the comments you can give.Thank you!
with
query_result as
(select 'Philly' acctloc, 15970 totalp Union double all the)
Select "NY", 8623 Union double all the
Select "Tacoma", 3 double Union all
Select "SanFran", 195 double Union all
Select "Hartford", 5 Union double all the
Select 'Miami', double 4374
)
Select acctloc, totalp, sum (totalp) on the_sum, avg (totalp) (on the_avg), ratio_to_report (totalp) (percentages))
of query_result
ACCTLOC TOTALP THE_SUM THE_AVG PERCENTAGES Philly 15970 29170 4861.66666666666666666666666666666666667 .547480287967089475488515598217346588961 NY 8623 29170 4861.66666666666666666666666666666666667 .295611930065135413095646211861501542681 Tacoma 3 29170 4861.66666666666666666666666666666666667 .000102845389098388755570791909496057593 SanFran 195 29170 4861.66666666666666666666666666666666667 .006684950291395269112101474117243743572 Hartford 5 29170 4861.66666666666666666666666666666666667 .000171408981830647925951319849160095989 Miami 4374 29170 4861.66666666666666666666666666666666667 .149948577305450805622214604045251971203 Concerning
Etbin
-
How to calculate the sum of two digital form fields based on the selection of the checkbox.
I have a form in Acrobat Pro who needs a custom calculation. How to calculate the sum of two digital form fields based on a selection of the checkbox. I have three number fields. Field-A and B are simple one or two digits. Field-C is the sum, or the total field. I want to field-C have a control box which, when turned on and off, just gives a. gives the sum of A + B
_ Field - 2
_ Field - A 4
[check] _ _ field - 6 C
[disabled] _ _ field - 2 C
Thank you
The custom field C calculation script could be:
(function () { // Get the values of the text fields, as numbers var v1 = +getField("A").value; var v2 = +getField("B").value; // Set this field's value based on the state of the check box named "CB" if (getField("CB").value !== "Off") { event.value = v1 + v2; } else { event.value = v1; } })();
Replace 'A', 'B', and 'CB' with the real names of the fields.
-
How to get the value of PMT in oracle?
Hi all
I need to calculate the value of the PMT
There is the Excel PMT function == > PMT (rate, nPer, PV, (FV), (TYPE))
I have to calculate using pl/sql.
Can any body help how to get the value of PMT in PL/SQL?
Thanks for your help.
Kind regards
IwantoThere is no Oracle built-in function to calculate the payments, but the formula is easy to find. If you look at using Excel PV function, you should find the formula that excel uses to calculate. You can rearrange the calculation in terms of payment. If FV and TYPE are 0, then the calculation is
PV*rate*power((1+rate),nPer)/(power((1+rate),nPer) - 1)
You don't need really PL/SQL to do this.
Kind regards
Bob -
Get the sum of all Member of a hierarchy.
Hello
I want to get the sum of each Member in a hierarchy.
The hierarchy is defined in the strdet table:create table strdet
The values for each object/material by costcenter (child) is defined in the details_det table:
(costcenterms varchar2(20), // parent
costcenterdet varchar2(20), // child
lev varchar2(1))create table details_det
Some examples of data:
(costcenterms varchar2(20),
eppid varchar2(30) ,
purchcontyear0 number(4,1) )insert into strdet values ('1' , '1.1','2')
/
insert into strdet values ('1' , '1.2','2')
/
insert into strdet values ('1.1' , '1.1.1','3')
/
insert into strdet values ('1.1' , '1.1.2','3')
/
insert into strdet values ('1.2' , '1.2.1','3')
/
insert into strdet values ('1.2' , '1.2.2','3')
/
insert into strdet values ('1.2' , '1.2.3','3')
/
insert into strdet values ('1.1.1' , '1.1.1.1','4')
/
insert into strdet values ('1.1.1' , '1.1.1.2','4')
/
insert into strdet values ('1.1.2' , '1.1.2.1','4')
/
insert into strdet values ('1.2.1' , '1.2.1.1','4')
/
insert into strdet values ('1.2.1' , '1.2.1.2','4')
/
COMMIT;insert into details_det values('1.1.1.1','epp1',10);
The desired sql stmt output should be like this:
insert into details_det values('1.1.1.1','epp2',20);
insert into details_det values('1.1.1.1','epp3',0);
insert into details_det values('1.1.1.2','epp1',0);
insert into details_det values('1.1.2.1','epp2',5);
insert into details_det values('1.1.2.1','epp4',15);
insert into details_det values('1.2.1.1','epp1',65);
insert into details_det values('1.2.1.1','epp2',95);
insert into details_det values('1.2.1.2','epp1',5);
commit;costcenter val
I wrote the following, so far...
-------------- ------
1 220
1.1 55
1.2 165
1.1.1 30
1.1.2 20
1.2.1 165SQL> select distinct s.costcenterms , sum(purchcontyear0) over(partition by s.costcenterms order by s.costcenterms)
How should I modify the above sql stmt to get the result you want...?
2 from details_det d , strdet s
3 where s.costcenterdet=d.costcenterms(+)
4 start with s.costcenterms='1'
5 connect by s.costcenterms = prior s.costcenterdet
6 order by s.costcenterms
7 /
COSTCENTERMS SUM(PURCHCONTYEAR0)OVER(PARTIT
------------------------------------------------------------ ------------------------------
1.2
1.2.1 165
1.1.1 30
1.1.2 20
1
1.1
6 rows selected
Note: I use OracleDB 10 g. v.2
Thank you very much
SIMsgalaxy wrote:
Anyway, since I want to use the sql stmt to define a materialized view, all versions of data of hierarchical queries are not allowed... (oracle ora-30361 error...).No error on my:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options SQL> create materialized view x_mv 2 as 3 select grp, 4 sum(purchcontyear0) 5 from ( 6 select connect_by_root s.costcenterms grp, 7 d.purchcontyear0 8 from strdet s, 9 details_det d 10 where s.costcenterdet=d.costcenterms(+) 11 connect by s.costcenterms = prior s.costcenterdet 12 ) 13 group by grp 14 / Materialized view created. SQL> select * 2 from x_mv 3 order by grp 4 / GRP SUM(PURCHCONTYEAR0) -------------------- ------------------- 1 215 1.1 50 1.1.1 30 1.1.2 20 1.2 165 1.2.1 165 6 rows selected. SQL>
SY.
-
How to get the text have the same effect as the video?
Hello
For the first time post here, but I wonder how to get the text of the titles have the same effect as the video behind her.
For my video, I use 'bad tv' and other effects such as Gaussian that obviously changes the appearance of video, creating the look of VHS. However, I then inserted text via the title, but it normally appears. How can I make this text have the same effects as the video behind it?
A friend told me I might need to add text to the video first, then do the effects, I have not tried, but wonder if there is an easier way, as this would require me to restart.
EDIT: That's what I'm looking for. https://youtu.be/7_2PHQI89dI?t=24s The text has the same effect as the video.
Thank you
One way is to create a clip made up based on the title and the original clip. Then apply the effect.
Another way is to use an adjustment layer.
Good luck.
Russ
-
How to get the podcast of the website on the phone
I was told to put that feed into the PODCASTING app on your iOS device.
The site in question is https://randirhodes.com/how-to-get-the-podcast/
I paid for a premium podcast, now how o I get this podcast to appear on my iphone 6 s more in the podcast app?
Podcasts > select my Podcasts > press the '+' > Add Podcast > paste the URL that you got on the site.
-
How to get the video intro off my google home screen I already saw it, where is the firefox logo used to be. I started with the last update that I rebooted.
Hello
to change the homepage when opening firefox-press 'Alt' and click on tools-> Options.Main menu, you can change the URL.
If the problem persists, you can follow these simple steps:
Enter about: config in the address bar and press ENTER. Accept the message of 'dragons' to see the Advanced preferences screen. Use the above search box to enter the below pref.
You can assign an empty string to stop your Firefox to retrieve "extracts" and brandLogo changes the browser.aboutHomeSnippets.updateUrl pref. Right-click this pref and select Edit then clear the value as pref in the box that appears, and then click OK. Who will also disable "snippets" that appear under the container of the research on the default home page.
Then you must open the folder of your profile, via help > Troubleshooting Information > profile folder > > button view folder. Then close Firefox. Your profile file open with Firefox closed (Firefox '3-bar' menu key > exit/Quit), wait or two minutes, then remove the storage\moz-safe-about + home folder in the Firefox profile folder to remove the brandLogo and stored in IndexedDB code snippets to make Firefox use the default brandLogo and a defined default code snippet.
If you later change your mind about these changes, you can reset the pref browser.aboutHomeSnippets.updateUrl via the context menu and Reset allows to retrieve the default value using the storage\moz-chest-fort-about + home folder again.
-
Heard speak adds the new on Fire Fox. Where and how to get the new Firefox add - one of who is spying on us. Please mail to maheshubhayakar at rediffmail.com
edited by email address - moderator
It is helpful if you provide a link to the article you were reading.
-
Re: How to get the Tempo to work properly?
Hello
I have problems with the service of Tempo.
I don't get updates via this application (all the settings of this application are accurate, i.e. "full control"). I know this because there are updates available online to my laptop via the pilot site of toshiba.
When I installed first Tempo, updates for about a month, I received, and then all of a sudden, no update came through. My firewall is blocking either of this application.
I tried to reinstall the application, but no change in the situation.
Does anyone know if ALL updates are available via the website of driver toshiba out tempo? Because, in the month that this service worked, I got an update of the bios, but I recently saw a bios update online and Tempo has not always reports that it is available.
Any ideas on how to get the Tempo to work properly?
Thank you.
I saw in your other thread you have installed SP1 on your Vista laptop.
There may be some compatibility problems between SP1 and TempoAnd Yes, as far as I know Tempo bring all available updates!
Maybe you are looking for
-
How can I make a phone call from Apple Watch after the update of the software lasted?
I don't know how to make a phone call from my Apple Watch after this update. I need help
-
FIREFOX CANNOT FIND MY PROFILE
OK so I have a weird FF problem where the old installation of FF would not be in service due to a starter kit on the computer of my EU who had been abducted, but broke things endangered. I googled and found the path to the profile of its FF and backe
-
Can't update (error 0 X 80070424)
original title; CAN NOT GET UPDATES, ERROR 0 X 80070424 EVERYTIME I TRY TO UPDATE WINDOWS I GOT ERROR 0 X 80070424 IVE TRIED TO > START > RUN SYSTEMROOT%\SYSTEM32\REGSVR32EXE.\SYSTEMROOT%\SYSTEM32\WUAUENG. DLL AND STILL I CAN'T GET UPDATES
-
Rather stupidly, I clicked on 'settings', then click 'manage toolbars', then click "do not show the toolbar command"... without realizing that the toolbar that I deleted was the icon for my home, work order offline and other things very convenient...
-
Processors for Windows 8.1 upgrade run XPS400 DXP051.
Windows 8 does not level to win 8.1 because Intel Pentium D CPU 2 .80GHz does not support the PrefetchW... Can someone suggest a processor that will work on a card mother Dell 0F030? What other inof is necessary to answer my question?