How to get the max total sale by date on every store
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Hi,
Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
Hjava wrote:
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Do you mean you want to see the store_id that had the maximum total sale?
In general, this can be done with a Top-N Query, using an analytic function such as RANK. For an example, see http://forums.oracle.com/forums/thread.jspa?messageID=3739610
If you only want the date, the maximum total from that date, and 1 column from the same row with the maximum (e.g. store_id), then you might be able to use the aggregate LAST function instead.
What results do you want in case of a tie? (That is, if 2 or mote store_ids have the same total sale on a given date, and no other store_id has a higher total.)
Similar Messages
-
How to get the Grand Total in Module pool Screen
Hi Frds.
How to get the Grand Total in Module pool Screen
Example i have 10 different materials
for each matarial has different moving . But in my case matarials is doesnt matter here
10 material Moving Average price to do Frand total and display in one column...
Please Help me out Frds.
Regards,
KabilHi
You need to calculate the total in a module of PAI (or PBO) event:
PROCESS PAI.
LOOP.....
ENDLOOP.
MODULE CALCULATE_TOTAL.
MODULE CALCULATE_TOTAL.
GRAND_TOTAL = 0.
LOOP AT ITAB,
GRAND_TOTAL = GRAND_TOTAL + ITAB-PWB.
ENDLOOP.
ENDMODULE.
In this way the grand total will be calculated as soon as the user presses enter or another command.
You can't insert the calculation in the loop of table control, because this loop runs the visible lines only, so it's better to calculate the total out of those loop, -
How to get the previous state of my data after issuing coomit method
How to get the previous state of some date after issuing commit method in entity bean (It should not use any offline storage )
>
Is there any way to get the state apart from using
offline storage ?As I said the caller keeps a copy in memory.
Naturally if it is no longer in memory then that is a problem.
>
and also what do you mean by auditlog?
You keep track of every change to the database by keeping the old data. There are three ways:
1. Each table has a version number/delete flag for each record. A record is never updated nor deleted. Instead a new record is created with a new version number and with the new data.
2. Each table has a duplicate table which has all of the same columns. When the first table is modified the old data is moved to the duplicate table.
3. A single table is used which has columns for 'table', 'field', 'data' and 'activity' (update, delete). When a change is made in any table then this table is updated. This is generally of limited useability due to the difficulty in recovering the data.
All of the above can have a user id, timestamp, and/or additional information which is relevant to the data being changed.
Note that ALL of this is persisted storage.
I am not sure what this really has to do with "offline storage" unless you are using that term to refer to backed up data which is not readily available. -
How to get the past top 100 match data of game app?
how to get the past top 100 match data of game app?
What game app? Have you contacted the developer of the app?
-
Hello BW gurus,
sorry for the incomplete question.
This is how i need my report.
Account Number Key Figure Type Company code Plant Sales Organization Fiscal year/period Z1/007.2006 Z1/008.2006 Z1/009.2006 Z1/010.2006 Z1/011.2006 Z1/012.2006
SALES x1
SALES x2
SALES x3
SALES x4
SALES x5
SALES x6
Overall Result SALES x1x2..x6
Similarly i need to get the cost of sales and its overall results
and then i have to get the gross margin as (Sales - Cost of Sales) for each fiscal period(columnwise).
i got the Sales and Cost of Sales like this
Plant Sales Organization Fiscal year/period
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
but i need all the sales data first and its total(S)
and then all the cost of sales data and its total(C)
and the gross margin (S-C) for individual fiscal period.
Please reply ASAP.Quick help is appreciated.
Thanks in advance,
Regards
Sam MathewHi Viraylab,
check <b>VBAP-NETPR</b> field of table <b>VBAP</b>
It gives the net price corresponding to a line item.
Goto Tcode VA03.See the <b>item overview</b> tab U will get <b>Net Price</b> field for indivisual line item.
Reward points if helpful.
Regards,
Hemant -
How to get the sum total of just one row in the dashboard
How do I get the sum total of one row in the compound layer results. This is 11g
Does anyone know?
may be sales, I need the total at the bottom of the row..
thx
ChuckI fnd the answer,
in the table view, click edit then nxt to the columns and measures there is total sum icon. Click that, and choose after -
HOW TO GET THE GRAND TOTALS IN ALV USING GRID FM
Hi,
I would like to know that am getting the sub totals using the ALV_GRID FM,
But I need Grand totals how i can get and what is the paramater to keep = x to get this Grand totals\.Hi,
If you have the DO_SUM = 'X' in the field catalog internal table for the corresponding column..Then you will get the grand total..
Thanks,
Naren -
How to get the max(level)?
Hi,
The below query returns level and other selected columns.
I need to get the max(level) 2nd column value in the below example.How to modify the query?
Ex
Level max(level) id
1 5 101
1 5 102
1 5 103
2 5 104
2 5 105
3 5 107
4 5 120
5 5 134
5 5 280
SELECT DISTINCT level lvl
,form_frms.emp_id
,form_frms.ing_emp_id
,form_frms.prve_id
,CASE
WHEN (select div_dn
from epm_prod epm
where epm.emp_id= form_frms.ing_emp_id) ='Y' THEN DIV_DN
WHEN NVL((select distinct 'N'
from emp_pro_version prvv
where prvv.is_py='Y' and
prvv.IS_VERSION ='N' and
prvv.emp_id=form_frms.ing_emp_id) ,'Y')='N'
THEN 'Y'
WHEN NVL((select distinct 'Y'
from employee epm
where emp.emp_id=form_frms.ing_emp_id
and epm.status<>'NEW') ,'N') ='Y'
THEN 'Y'
ELSE 'N'
END
ELSE 'N'
END UN_KNOWN_ID
FROM (SELECT empvv1.prvv_id
FROM emp_view_version empvv1
WHERE empvv1.is_version = 'Y'
) form_frms
START WITH form_frms.emp_id = :lv_emp_id
CONNECT BY PRIOR form_frms.ing_emp_id = form_frms.emp_id
ORDER BY level DESC, form_frms.emp_id,UNKNOWN_ID ASC;
Edited by: shivasha on Feb 9, 2013 12:24 AMMaybe
select lvl,
max(lvl) over (order by null rows between unbounded preceding and unbounded following) max_level,
emp_id,
unknown_id
from (SELECT DISTINCT
level lvl,
form_frms.emp_id,
form_frms.ing_emp_id,
form_frms.prve_id,
CASE WHEN (select div_dn
from epm_prod epm
where epm.emp_id = form_frms.ing_emp_id
) = 'Y'
THEN DIV_DN
WHEN NVL((select distinct 'N'
from emp_pro_version prvv
where prvv.is_py = 'Y'
and prvv.IS_VERSION = 'N'
and prvv.emp_id=form_frms.ing_emp_id
),'Y'
) = 'N'
THEN 'Y'
WHEN NVL((select distinct 'Y'
from employee epm
where emp.emp_id = form_frms.ing_emp_id
and epm.status != 'NEW'
),'N'
) = 'Y'
THEN 'Y'
ELSE 'N'
END UNKNOWN_ID
FROM (SELECT empvv1.prvv_id
FROM emp_view_version empvv1
WHERE empvv1.is_version = 'Y'
) form_frms
START WITH form_frms.emp_id = :lv_emp_id
CONNECT BY PRIOR form_frms.ing_emp_id = form_frms.emp_id
ORDER BY lvl DESC,emp_id,UNKNOWN_IDRegards
Etbin -
How to get the measure total at row level for another measure calculation in DAX?
Hi There,
Using DAX, I am trying to get an expression for a calculated measure as follow:
So basically, I would like to get the AMeasure total highlighted in yellow in the A2Measure calculation:
Smeasure -(Ameasure total * WMeasure) where Ameasure total is the one highlighted.
I think my question would be how to get the total of a measure in order to used in the calculation of another measure.
Thanks and best regards,
JossHi Joss83,
If you're trying to get the result for [AMeasure] at the total level (i.e. 5.09 in your example) you can do this by creating a version of this measures that is evaluated after ignoring the filters (indirectly or explicitly) placed on
the 'Customer' and 'Player' columns. You may also need to ignore the filters place on some other tables or columns that must be ignored in order for the correct total to be returned.
Without knowing much more about your data model, I can only take a vague guess as to what this calculation would look like in your scenario:
AMeasureTotal:=
CALCULATE(
[AMeasure],
ALL(Customer[Customer]),
ALL(Player[Player])
You can read more about the 'ALL' DAX function here:
http://technet.microsoft.com/en-us/library/ee634802.aspx
Hope this helps,
Michael -
how to get the record with the max sequence no
table as
seq student mark
1 A 10
2 A 15
1 B 20
2 B 10
1 C 30
here is what i need
seq student mark
2 A 15
2 B 10
1 C 30i have used your query + some decode
With t As
Select 'A' st, 'X' Type, 1 seq, 001 marker_no, 10 mark From dual Union All
Select 'A', 'X', 2, 001, 12 From dual Union All
Select 'B', 'X', 1, 002, 10 From dual Union All
Select 'B', 'X', 2, 003, 12 From dual Union All
Select 'B', 'X', 3, 003, 15 From dual Union All
Select 'C', 'X', 1, 001, 10 From dual Union All
Select 'C', 'X', 2, 002, 15 From dual Union All
Select 'C', 'Y', 3, 001, 20 From dual Union All
Select 'C', 'Y', 4, 001, 10 From dual
Select st,
Sum (x_cnt) x_cnt,
Max (x_seq) Keep (dense_rank Last Order By x_seq) x_seq,
max(x_marker_no) keep(dense_rank last order by x_seq) x_marker_no,
max(x_mark) keep(dense_rank last order by x_seq) x_mark,
sum(y_cnt) y_cnt,
max(y_seq) keep(dense_rank last order by y_seq) y_seq,
max(y_marker_no) keep(dense_rank last order by y_seq) y_marker_no,
max(y_mark) keep(dense_rank last order by y_seq) y_mark
from
(Select st,
decode(Type ,'X',1,0) x_cnt,
decode(type ,'X',seq,0) x_seq,
decode(Type ,'X',marker_no,0) x_marker_no,
decode(Type ,'X',mark,0) x_mark,
decode(Type ,'Y',1,0) y_cnt,
decode(Type ,'Y',seq,0) y_seq,
decode(Type ,'Y',marker_no,0) y_marker_no,
decode(Type ,'Y',mark,0) y_mark
From t
Group By st;
/*this is the output
st X_cnt X_seq X_marker_no X_mark Y_cnt Y_seq Y_marker_no Y_mark
A 2 2 001 12 0 null null null
B 3 3 003 15 0 null null null
C 2 2 002 15 2 4 001 10
ST X_CNT X_SEQ X_MARKER_NO X_MARK Y_CNT Y_SEQ Y_MARKER_NO Y_MARK
A 2 2 1 12 0 0 0 0
B 3 3 3 15 0 0 0 0
C 2 2 2 15 2 4 1 10 -
How to get the max value of a set of percentage values?
Hi,
I've tried to get the max and min value of a set of calculated percentage values. Such as
Jan Feb March Apr May Jun Min Average Max
0,5 0,8 1,1 0,4 1 0,6 0,4 0,7 1,1
The average value works fine. But with "min" and "max" I have a problem.
I've tried to get the value with the following ways:
- Create a new calc. keyfigure and make a sum of all values: (Jan + Feb + ...) and set the calculation in key figure properties to Min/Max.
- Create a new calc. keyfigure and make a sum of all values and set the aggregation to Min/Max
- Create a selected keyfigure with a filter to the necessary periods and set a calculation to Min (Aggregation is not possible here)
- Create a new cal. keyfigure with all periods and the function Min. e.g. min(Jan, (min Feb, (min (....)
None of this solutions provides the right min and max value. When I use an amount value (e.g. Euro) instead of these percentage values the keyfigure with the min and max function works. The others all provide wrong values.
Is there a solution to get the right min and max value???
It would be a great help when you have any hints.
Thanks
ClaudiaHi Aduri,
thanks for your answer but your solution doesn't work.
The problem is that the periods are defined in a structure with offsets such as
- period-11
- period-10
- period
in this structure elements there is also the keyfigure "netvalue" defined.
In the rows of the report there is another characteristic such as company code.
Is there a solution to find the max and min values of the period values for each company code? Or must I change the data model e.g. copy the keyfigure and make a new keyfigure with another aggregation level?
Thanks for any hints!
Claudia -
How to get the group totals in report
HI,
Iam generating a report to display Storage Location, and Unit of Measures and Material group and also group totals.
how to display the group totals on the report.
thank q
rushi.Hi,
This following report clearly explains how to display the subtotal and grand total of
the particular field in alv.
REPORT YMS_ALVSUBTOTAL.
*REPORT z_alv_sub_totals .
TYPE-POOLS: slis.
DATA: BEGIN OF it_output OCCURS 0,
var1(8) TYPE n,
var2(10),
var3 TYPE I,
END OF it_output.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
t_fieldcat TYPE slis_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
t_sort TYPE slis_sortinfo_alv,
v_repid LIKE sy-repid.
INITIALIZATION.
v_repid = sy-repid.
START-OF-SELECTION.
PERFORM get_data.
PERFORM sort_fields.
PERFORM fill_fieldcat.
PERFORM list_display.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM get_data.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
it_output-key = 'X'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'siddhu'.
it_output-var3 = '20000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'chinni'.
it_output-var3 = '100000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'chicchu'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'candy'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 4000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
ENDFORM. " GET_DATA
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
ENDFORM. " fill_fieldcat
*& Form fill_fields
text
-->P_0146 text
-->P_0147 text
-->P_0148 text
-->P_0149 text
FORM fill_fields USING value(tabname) TYPE slis_tabname
value(fieldname) TYPE slis_fieldname
value(seltext_m) LIKE dd03p-scrtext_m
value(do_sum) TYPE c.
t_fieldcat-tabname = tabname.
t_fieldcat-fieldname = fieldname.
t_fieldcat-seltext_m = seltext_m.
IF do_sum = 'X'.
t_fieldcat-datatype = 'CURR'.
ENDIF.
t_fieldcat-do_sum = do_sum.
APPEND t_fieldcat TO it_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " fill_fields
*& Form list_display
text
--> p1 text
<-- p2 text
FORM list_display.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = it_fieldcat
it_sort = it_sort[]
TABLES
t_outtab = it_output
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " list_display
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM sort_fields.
t_sort-fieldname = 'VAR1'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 1.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
t_sort-fieldname = 'VAR3'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 2.
t_sort-up = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
ENDFORM. " sort_fields
Thanks,
Sankar M -
How to get the max value in the query??
Plant calday(mm.dd.yyyy) Soldout.Qty
0001 01.01.2005 10
0001 01.02.2005 20
0001 01.03.2005 05
0001 01.04.2005 16
0001 01.05.2005 10
0001 01.06.2005 14
From the above values , how can i findout Max(Soldout.Qty)(i.e 20) for the above week...Suppose present aggregation = summation...How can i findout the value in the Query??don't want to do changes to design...Hi Bhanu,
I tried the calculation results as...Maximum,..
But that will pick the maximum value among the avialable values..like
plant1 max 10
plant2 max 20
plant3 max 30
then it will show as..
plant1 max 30
plant2 max 30
...like this...but my case is
plant1 calday1 10
plant1 calday2 05
plan1 calday7 08
plant2 calday1 10
plant2 calday2 05
plan2 calday7 20
so for each set it need to bring the maximum value... -
How to get the Max value of elements of type datetime
Hi All ,
I wanted to get the latest timestamp value ( datatype as datetime) from node list. I have following xml. In this xml, i want to get the modifydate element which has latest timestamp through xquery/xpath, it should return me following result 2011-09-29T17:21:17+10:00
<CustomerList>
<CustomerDetails>
<name> Test 1</name>
<status>active</status>
<modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
</CustomerDetails>
<CustomerDetails>
<name> Test 2</name>
<status>cancel</status>
<modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
</CustomerDetails>
<CustomerDetails>
<name> Test 3</name>
<status>active</status>
<modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
</CustomerDetails>
</CustomerList>
i tried to use the
//CustomerList/CustomerDetails/modifyDate[not(. <=../preceding-sibling::CustomerList/CustomerDetails/modifyDate) and not(. <=../following-sibling::CustomerList/CustomerDetails/modifyDate)]
But it is not working on datetime datatype.
Any help in this regard is much appreciated.
Regards
Edited by: user6736659 on Sep 5, 2011 6:15 AMHi,
The following XQuery should give you what you want :
max(
for $i in /CustomerList/CustomerDetails/modifyDate
return xs:dateTime($i)
)For instance, using Oracle SQL :
SQL> var xmldoc varchar2(4000)
SQL> begin
2 :xmldoc := '<CustomerList>
3 <CustomerDetails>
4 <name> Test 1</name>
5 <status>active</status>
6 <modifyDate>2011-08-20T17:21:17+10:00</modifyDate>
7 </CustomerDetails>
8
9 <CustomerDetails>
10 <name> Test 2</name>
11 <status>cancel</status>
12 <modifyDate>2011-08-29T17:21:17+10:00</modifyDate>
13 </CustomerDetails>
14
15 <CustomerDetails>
16 <name> Test 3</name>
17 <status>active</status>
18 <modifyDate>2011-09-29T17:21:17+10:00</modifyDate>
19 </CustomerDetails>
20 </CustomerList>';
21 end;
22 /
PL/SQL procedure successfully completed
SQL> select xmlquery('max(
2 for $i in /CustomerList/CustomerDetails/modifyDate
3 return xs:dateTime($i)
4 )'
5 passing xmltype(:xmldoc)
6 returning content
7 )
8 from dual
9 ;
XMLQUERY('MAX(FOR$IIN/CUSTOMER
2011-09-29T17:21:17.000000+10:00 -
How to get the grand total ?
Hi all,
I got 1 main query say Q1 link to another 3query, Q2, Q3 & Q4. In Q2, Q3 & Q4, I got the difference qty display based on individual repeating frame. Now if I need to sum the grand total of Q2, Q3 & Q4 ? how should I do ?
I try to put the sumary up in Q1, but the system has given REP-1517 error.
Any idea please help me. Thanks.
Rgds
LimAdd summary columns in your data model. Where to put them exactly depends on your report. E.g. if you want a grand total at the end of the report, you create the column outside the query. The Object Navigator shows a Summary Columns node beneath the Queries node for these columns.
Maybe you are looking for
-
Error Message Repeated Display When using BBP_DOC_CHECK_BADI
Hi,EveryOne, Who can help me,I am using BBP_DOC_CHECK_BADI,Check the item's,when the first time,i modify some PO item data,then through this BBP_DOC_CHECK_BADI,can show one error message.Then i modify the error data to correct,push the check butt
-
Windows 8 and Photoshop Elements
I need to uninstall Photoshop Elements before I can install Windows 8. Will I be able to re-install from Adobe on the web? How do i find any serial numbers or other such security stuff so they know i already own it.?
-
My ipad 1 crashes so I want to install a fresh ios 5.1.1. Everytime I try to re-install it gives me a corrupt download message. I've tried wireless and wired. On my ipad 4 my apps sometimes download and other times fail. I cannot connect to itunes e
-
Hi All, I am doing IDOC to File Scenario where i am sending Purchase order details to third party system. When i create or change the PO it should generate ORDER05 idoc and send to PI. I configured output type to generate PO idoc but it is not genera
-
Comp Planning MSS iview display
Hi All, I am currently working on LTI plans ECM and on the compensation planning iview on the portal, ones the manager selects the org unit, it displays all the employees belonging to the org unit with the status as eligible or ineligible for the LTI