Help in select and sum
hi
i have to fo select from table in data base (ztrm_1)that have field like
(p01 p02 p03 p04 p05 p06 p07 p08 p09 p10 p11 p12)
and i have to sum all content of this field into one field (sum_last)
what is the <b>best</b> way to do that?
i reward
Regards
Hello tal_s
data : it_ztrm_1 type table of ztrm_1,
p0 type ztrm_1-p01
selct * from ztrm_1 into table it_ztrm_1.
loop at it_ztrm_1 into wa_ztrm_1
do 12 times varying p0 FROM wa_ztrm_1-p01 NEXT wa_ztrm_1-p02.
w_sum = w_sum + p0
enddo.
append w_sum to it_sum " if multiple records.
endloop.
if you have single record then no need of outer loop directly use do enddo statement on your wrk area
hope p01 p02 ,p03 ... are of same type & length.
this should solve your problem
reward points if helpful
Similar Messages
-
Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
SELECT 'ST' LEDGER,
CASE
WHEN c.Category = 'E' THEN 'Headcount Exempt'
ELSE 'Headcount Non-Exempt'
END
ACCOUNTS,
CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
'MARCH_12' AS PERIOD,
COUNT (a.empl_id) head_count
FROM essbase.employee_pubinfo a
LEFT OUTER JOIN MMS_DIST_COPY b
ON a.cost_ctr = TRIM (b.bu)
INNER JOIN MMS_GL_PAY_GROUPS c
ON a.pay_group = c.group_code
WHERE a.employee_status IN ('A', 'L', 'P', 'S')
AND FISCAL_YEAR = '2012'
AND FISCAL_MONTH = 'MARCH'
GROUP BY a.company,
b.district,
a.cost_ctr,
c.category,
a.fiscal_month,
a.fiscal_year;
which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?Hi,
Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
user610131 wrote:
... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
You may want both a sub-query and a different GROUP BY clause. For example:
WITH got_group_by_columns AS
SELECT a.empl_id
, CASE
WHEN c.category = 'E'
THEN 'Headcount Exempt'
ELSE 'Headcount Non-Exempt'
END AS accounts
, CASE
WHEN a.company = 'ZEE'
THEN 'OH'
ELSE 'NA'
END AS market
FROM essbase.employee_pubinfo a
LEFT OUTER JOIN mms_dist_copy b ON a.cost_ctr = TRIM (b.bu)
INNER JOIN mms_gl_pay_groups c ON a.pay_group = c.group_code
WHERE a.employee_status IN ('A', 'L', 'P', 'S')
AND fiscal_year = '2012'
AND fiscal_month = 'MARCH'
SELECT 'ST' AS ledger
, accounts
, market
, 'MARCH_12' AS period
, COUNT (empl_id) AS head_count
FROM got_group_by_columns
GROUP BY accounts
, market
;But that's just a wild guess.
You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
Edited by: Frank Kulash on Apr 4, 2012 5:31 PM -
How to select and sum internal table records
Dear Friends
I kindly ask you if we have select statement
if s_mtart = 'z003'
select single pvprs from ckmlcr into ckmlcr-pvprs
where poper EQ s_poper and
kalnr = itab2-kalnr and
bdatj = itab2-bdatj and
curtp = itab2-curtp.
like this how can I calculate how many record it got and I want to get summation of this field(pvprs).And for all poper's must contain.
Please Let me remind you my itab is already open I didn't put any thing for this situationit seems to be you written this SELECT in a loop. if so,
instead of pushing the values into ckmlcr-pvprs ,create an internal table
data : begin of itab,
pvprs type ckmlcr-pvprs ,
end of itab.
then just after that SELECT SINGLE,
select single pvprs from ckmlcr <b>into ITAB-pvprs</b>
where poper EQ s_poper and
kalnr = itab2-kalnr and
bdatj = itab2-bdatj and
curtp = itab2-curtp.
IF SY-SUBRC = 0.
APPEND ITAB.
here either you can use APPEND OR COLLECT.
If you use COLLECT,all the values will get summed up and final sum will be in the table ITAB-pvprs.
ENDIF.
After all loops your itab will have the totals.
DESCRIBE TABLE ITAB LINES V_LINES.
V_LINES Will have total no of lines.
Regards
srikanth -
Hi experts,
i have requirement to write end routine to read a DSO for last 12 months sales quantity for each month and sum value pass to keyfigure
not interested using bex variable, while data loading from source to target dso in end routine i am trying to read another DSO which is same as my
target dso where information is stored by fiscal period, year material etc. finally there is a keyfigure in target whih needs to be filled with sum of 12
months sales quantity, for each record form sourc to target maximum of 12 records will be in read dso (for 12 months) my routine is like below.
i am not expert in abap please kindly gothrough and guide me in this
TYPES: BEGIN OF s_/BIC/AZOSLS00,
FISCPER type /BI0/OIFISCPER,
FISCVARNT type /BI0/OIFISCVARNT,
PLANT type /BI0/OIPLANT,
STOR_LOC type /BI0/OISTOR_LOC,
/BIC/MATERIAL type /BIC/OIMATERIAL,
VTYPE type /BI0/OIVTYPE,
BILL_QTY type /BI0/OIBILL_QTY,
END OF s_/BIC/AZOSLS00.
DATA: it_/BIC/AZOSLS00 TYPE TABLE OF s_/BIC/AZOSLS00,
wa_/BIC/AZOSLS00 TYPE s_/BIC/AZOSLS00.
SELECT
FISCPER
FISCVARNT
PLANT
STOR_LOC
/BIC/MATERIAL
VTYPE
BILL_QTY
FROM /BIC/AZOSLS00 INTO TABLE it_/BIC/AZOSLS00
FOR ALL
ENTRIES IN RESULT_PACKAGE
WHERE
below field is from value of fiscal period (which is fiscal period -999 ex: for 001.2014 this
value will be 002.2013 so 12 months including current period)
FISCPER >= RESULT_PACKAGE-/BIC/ZFISCPERF
below is result filed fiscal period (here i dont know which keyword or statement to be used to select
interval values this between statement giving syntax error that can not be used in where for for all entries
between RESULT_PACKAGE-FISCPER
AND
FISCVARNT = RESULT_PACKAGE-FISCVARNT AND
PLANT = RESULT_PACKAGE-PLANT AND
STOR_LOC = RESULT_PACKAGE-STOR_LOC and
/BIC/MATERIAL = RESULT_PACKAGE-/BIC/MATERIAL .
SORT it_/BIC/AZOSLS00 BY FISCPER FISCVARNT PLANT STOR_LOC
/BIC/MATERIAL .
LOOP AT RESULT_PACKAGE ASSIGNING <result_fields>.
READ TABLE it_/BIC/AZOSLS00 INTO wa_/BIC/AZOSLS00 WITH KEY
below dont know what statement i need to use in read statement for interval of fiscal periods
giving error that >= can not be used
FISCPER >= <result_fields>-/BIC/ZFISCPERF
FISCPER = <result_fields>-FISCPER
FISCVARNT = <result_fields>-FISCVARNT
PLANT = <result_fields>-PLANT
STOR_LOC = <result_fields>-STOR_LOC
/BIC/MATERIAL = <result_fields>-/BIC/MATERIAL
BINARY SEARCH.
BREAK-POINT.
IF sy-subrc = 0.
below for each record there will be 12 records in read so sume of 12 records quantity i need to pass to result again dont know what to say here
sum statement giving error
<result_fields>-/BIC/ZLSTSLS12 =
sum(wa_/BIC/AZOSLS00-BILL_QTY).
ENDIF.
ENDLOOP.
friends please help me in this.
Thanks
Chandra.Hiii,
If you only want to store last 12 months data in Target ODS .
Then Create filter in DTP and write routine in filter for calmonth or fiscal period.
Refer the below link to create filter routine :
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/80b2db87-639b-2e10-a8b9-c1ac0a44a7a6?QuickLink=index&…
Regards,
Akshay -
How do I transfer my checked songs from one computer to another - tried exporting library playlist etc but no luck! Please help! I have 26,000 songs - 17,000 are selected and I can't run down the list on my new computer and re-check 17,000 songs! Thanks!
Make a smart playlist of your whole library but only checked songs - #4 on http://support.apple.com/kb/ht1801
Highlight all files in that playlist, then drag to the other drive. This isn't preserving any playlists or whatever, just copying files from one drive to another.
You might want to delete the smart playlist this once you are done because it will probably gobble up resources with that many files. -
How do I import or move multiple selected photos to an existing album in iPhoto 9.6? In previous versions I could select and drag multiple photos into an album. Now I can only move one photo at a time. Help!
Try this general troubleshooting procedure:
1 - delete the iPhoto preference file, com.apple.iPhoto.plist, that resides in your
User/Home/Library/ Preferences folder.
2 - delete the contents the following folder: User/Library/Containers/com.apple.iPhoto
3 - reboot, launch iPhoto and try again.
NOTE: For Mavericks and Yosemite, go to your Home folder and use the View ➙ Show View Options menu to bring the this window:
where you can check the Show Library Folder checkbox. -
Help with selecting files from script menu or drag and drop
I found this scale images applescript online. It works great when a bunch of files is dragged on top of the script but I would like it to also work when a folder or group of files is selected in the Finder and I activate it from the scripts menu.
I can't get my on run statement to work. I'm not really an Applescript guy so I'm really just asking if someone can help finish what I started in this on run.
-- save in Script Editor as Application
-- drag files to its icon in Finder
property target_width : 120
property save_folder : ""
on run
tell application "Finder"
activate
set folder_path to quoted form of (POSIX path of (the selection as alias))
set theItems to every file of folder_path
end tell
end run
on open some_items
-- do some set up
tell application "Finder"
-- get the target width, the default answer is the property target_width
set new_width to text returned of ¬
(display dialog "Target width:" default answer target_width ¬
buttons {"OK"} default button "OK")
if new_width as integer > 0 then
set target_width to new_width
end if
-- if the save_folder property has not been set,
-- set it to the folder containing the original image
if save_folder is "" then
set save_folder to ¬
(container of file (item 1 of some_items) as string)
end if
-- get the folder to save the scaled images in,
-- default folder is the property save_folder
set temp_folder to ¬
choose folder with prompt ¬
"Save scaled images in:" default location alias save_folder
set save_folder to temp_folder as string
end tell
-- loop through the images, scale them and save them
repeat with this_item in some_items
try
rescaleand_save(thisitem)
end try
end repeat
tell application "Image Events" to quit
end open
on rescaleand_save(thisitem)
tell application "Finder"
set new_item to save_folder & "scaled." & (name of this_item)
end tell
tell application "Image Events"
launch
-- open the image file
set this_image to open this_item
set typ to this_image's file type
copy dimensions of this_image to {current_width, current_height}
scale this_image by factor (target_width / current_width)
save this_image in new_item as typ
end tell
end rescaleandsaveWhen items are dragged to your script's icon they are passed in to the on open handler, so this triggers:
on open some_items
and the dragged items are passed in as some_items
In contrast, when you double-click on the script, or invoke it via the Script menu, this runs the on run handler:
on run
tell application "Finder"
activate
folder_path to quoted form of (POSIX path of (the selection as alias))
set theItems to every file of folder_path
end tell
end run
However, there's nothing in this block that actually does anything with the selection - you (dangerously) assume that the selection is a folder (you really should check first), and just set theItems to every file in that folder then you exit.
So to do what you want you'll need to edit your run handler to filter the selection and pass files over to the code that does the hard work.
You already have the basis for this - your rescaleandsave() handler, so it's just a matter of identifying the files in the selection and passing those over to that handler:
on run
tell application "Finder"
set cur_selection to (get selection) -- get the selection
repeat with each_item in cur_selection -- iterate through
if class of each_item is folder then -- do we have a folder?
set theFiles to every file of each_item -- if so, get its contents
repeat with each_file in theFiles -- iterate through them
my rescaleand_save(eachfile) -- and process them
end repeat
else if class of each_item is document file then -- do we have a file selected?
my rescaleand_save(eachitem) -- if so, process it
end if
end repeat
end tell
end run
So the idea here is that the run handler gets the selection and works through the (potentially-numerous) items. For each selected item it checks whether its a folder or a file, if its a folder it gets all the files within and passes them to the rescaleandsave handler.
Note that this is not recursive - it won't catch files within folders within folders - since it only looks at the top level of selected folders, but it wouldn't be hard to rework the script to handle that if that's what you need. -
It goes nuts for hours and the next day it acts completely fine. My macbook is impossible to work with when the problem is active; it randomly clicks, drags, selects and even selects words (in a yellow colour) to come up with latin(?!) translations.
Ive tried the reset (option+cmd+r+p) and it seemed to work at first but now it doesnt seem to have any effect whatsoever.
Also tried to apply pressure to the entire surface of the trackpad or just the top corners; no effect whatsoever.
It's been quite an expensive purchase for a young student like me and i've really enioyed it until last week.
I'd be relieved if someone came up with a solution; especially since its warranty has expired for half a year now.Hi there Bram3,
You may find the troubleshooting steps in the article below helpful.
Portables and Magic Trackpad: Jumpy or erratic trackpad operation
http://support.apple.com/kb/ts1449
-Griff W. -
Date selection and search help component in jsp
Hi all:
In sap portal jsp development enviorment, is it possible to easily program the date selection and search help ( just look like search help in webdynpro ) ?Hello Jianhong,
the easiest way to set a value help is using HTMLB component in your JSP.
To do it, use next code:
<hbj:inputField
id="DateInputField"
type="date"
showHelp="TRUE"
... other attributes
/>
Before using HTMLB components in your JSP, don't forget to add this line to your page:
<%@ taglib uri= "tagLib" prefix="hbj" %>
regards.
mz -
I have a Macbook Air (july 2012) with OS X 10.8.3 installed. I have dvds with .vob files and have Quicktime Version 10.2 (603.12). I can't play the DVDs. There are some features of QT that I like, e.g. precise frame selection and save as .png file-help. Am I missing some Apple software? I thought QT for Mountain Lion could convert the .vob files - is there some setting that I have missed?
Any suggestions that preserves a simple workflow much appreciated.arthur wrote:
Perian is here: Perian - The swiss-army knife of QuickTime® components
Perian will be retired soon. -
I need to select and upload a image and corresponding url from an external website using file upload control in MVC4.
Please help
Latheesh K Contact No:+91-9747369936This forum supports .NET Framework setup.
As your issue appears to have nothing to do with .NET Framework setup, please ask in the MVC forums for best support.
http://forums.asp.net/1146.aspx/1?MVC -
Supress 'Further Selection' And 'Search Help' buttons from LDB selection sc
Hi,
How to supress/invisible 'Further Selection' And 'Search Help' buttons from LDB selection screen?
waiting for reply.
Shweta.Hi,
1) try to use another version of sel-screen
2) work with loop at screen:
LOOP AT SCREEN.
CASE SCREEN-NAME.
WHEN 'ANLAGE-LOW' OR 'ANLAGE-HIGH'
OR '%_ANLAGE_%_APP_%-TEXT'
OR '%_ANLAGE_%_APP_%-VALU_PUSH'
OR '%_UNTNR_%_APP_%-TEXT'
OR 'UNTNR-LOW' OR 'UNTNR-HIGH'
OR '%_UNTNR_%_APP_%-VALU_PUSH'
OR 'BEREICH2' OR 'BEREICH3'.
SCREEN-INVISIBLE = 1.
SCREEN-INPUT = 0.
SCREEN-OUTPUT = 0.
WHEN 'BUKRS-LOW'.
SCREEN-REQUIRED = 1.
WHEN OTHERS.
CONTINUE.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
A. -
HELP ! why doesn't color picker select specific color ? i make secondary layer and use the tool but no colors are selected and the gray out menu shows nothing !
what am i missing ??!!Please add you system info and SpeedGrade version and build number if you actually want help.
-
html:select and html:options simple question - please help
Hi Friends,
I am having a problem, please help me .I want to run a query and display all the lastnames of all the users in my database.Here are my files:
UserForm.java
public class UserForm extends ActionForm{
private name firstName;
private name lastName;
//all getter and setters
viewuser.jsp
<html:select property="lastName">
<html:options collection="users" property="lastName" labelProperty="lastName" />
</html:select>
and my Java Utility class method
public ArrayList getusers() throws Exception {
ArrayList aList = new ArrayList();
Connection con = ConnectionUtil.getConnection();
PreparedStatement stmt = null;
try {
stmt = con.prepareStatement("select last_name from USERS);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
aList.add(rs.getString(1));
}else {
return null;
rs.close();
return aList;
} catch (SQLException e) {
e.printStackTrace();
throw new ServiceProcessingException(e.getMessage());
} finally {
ConnectionUtil.closeStatement(stmt);
ConnectionUtil.closeConnection(con);
}My problem is what i need to do in my Action class,so that it sets the "users" variable
properly and i would be able to read that variable in my jsp and display the lastname
of all the users.I am tryin this but failing badly:
public class UserAction extends Action{
ArrayList userssList = Utility_class_obj.getUsers();
request.getSession().getServletContext().setAttribute("users", usersList);Please Please help,I would really appreciate your help.
ThanksThanks a lot friend...this time i made it work my style,next time i will use tha mehod.But I think I am not doing it the right way,please correct me:
This is the method in my utility class where i run the query and I doubt I am not doing it right here:
PreparedStatement stmt = null;
ViewForm vForm = null;
try {
stmt = con.prepareStatement("SELECT LAST_NAME FROM USERS_ADD"); \
ResultSet rs = stmt.executeQuery();
while(rs.next()) {
vForm = new ViewForm(rs.getString(1));
aList.add(vForm);
rs.close();
return aList; }
}And I made this constructor in my viewForm class:
public ViewForm(String lastName){ this.setLastName(lastName); }I do this in my Action class then:
ArrayList pList = csDAO.getUsers();
if(pList != null){
request.getSession().getServletContext().setAttribute("plist", pList);
}And finally this in my jsp:
<html:select property="lastName">
<html: options collection="plist" property="lastName" labelProperty="lastName" /> And it works,but i don't think I can keep adding constructors to my form class like that,and moreoever if I want to search by first name ,there would be a conflict between 2 constructors,so can someone please tell me the right way to do this.
Thanks
Mick -
Holding 'select' and 'menu' at the same time doesn't help. What now?
First, the only thing that would happen when trying to turn it on was that it would show a message with the Ipod support website but nothing else. Now it doesn't even turn on. Pressing 'select' and 'menu' at the same time doesn't help and it is not on Hold. Any ideas or is it just dead?
I have the same problem, only not so far gone. My iPod keeps showing me the logo for a couple seconds, then a red X that tells me to go to apple.com/support. I have been here several times and tried the five R's and nothing has worked. My iPod is also charged and the hold isn't on. My computer isn't recognizing that it is hooked up, my warranty is up and this is my second iPod. My first one's death was completely my fault, but I did nothing to prompt this lock down. I am about ready to try some of the risky hints online to get it to work but I would like something less extreme than taking the thing apart.
Maybe you are looking for
-
Any body now what is this message : javax.servlet.jsp.JspException: REP-56092: Nenhuma classe definida para o tipo de destino Tela javax.servlet.jsp.JspException: REP-56092: Nenhuma classe definida para o tipo de destino Tela at oracle.reports.j
-
Revision: 14330 Revision: 14330 Author: [email protected] Date: 2010-02-22 10:03:03 -0800 (Mon, 22 Feb 2010) Log Message: BLZ-476 : Getting different error message in server's servlet log and console log when class is not of expected type. QA:
-
I have a real problem with doing a batch update in SOA Suite and have tried a number of different approaches but they have all failed at some point. My requirement is really quite simple. I have a simple table - MY_TABLE: Columns: PK_ID - primary key
-
Hi Experts, I have an issue to solve. While creating a PO using drag & drop, sometimes users are overlooking the delivery date which lies in the past.I want to control delivery date atleast to current date eventhough users skips changing delivery da
-
Wrong RAM Size Detected with KT4 Ultra
I am using 2 Crucial PC2100 256 MB DDR Modules. Neither they nor the motherboard ever overclocked. Even I used them under auto settings. They were working fine as 512 MB after I first installed my system but I noticed today that the board detects ins