How to find data's from table whose sum=given input.
Hi all,
how to find values whose sum=given value.
i have a master. table
master table
name amount
a 1000
b 6000
c 2000
d 1500
input amount=4500 (may change);
how to get name from master table whose sum(amount)=4500;
i.e) a,c,d as output.
Hi,
I realy like the approach you made.
But it is not realy scalable, as you probably know already.
I tried the following:
WITH
master_table as
select 'a' name, 1000 amount from dual union all
select 'b', 700 from dual union all
select 'c', 2000 from dual union all
select 'd', 300 from dual union all
select 'e', 1000 from dual union all
select 'f', 1200 from dual union all
select 'g', 2300 from dual union all
select 'h', 500 from dual union all
select 'i', 400 from dual union all
select 'j', 600 from dual union all
select 'k', 700 from dual union all
select 'l', 400 from dual union all
select 'm', 500 from dual union all
select 'n', 600 from dual union all
select 'o', 700 from dual union all
select 'p', 800 from dual union all
select 'q', 900 from dual union all
select 'r', 1000 from dual union all
select 's', 1700 from dual union all
select 't', 1400 from dual
,got_name_list AS
SELECT LTRIM ( SYS_CONNECT_BY_PATH (name, ',')
) AS name_list
, SYS_CONNECT_BY_PATH (amount, '+') AS amount_list
FROM master_table
CONNECT BY name > PRIOR name
AND amount < :target_amount
SELECT name_list, amount_list
FROM got_name_list
WHERE XMLQUERY ( (amount_list)
RETURNING CONTENT
).getnumberval () = :target_amount
;And indead I received a solution. But it toke 788 seconds.
I think that if you want to use this with more rows you have to find a PL/SQL solution.
Regards
Peter
Similar Messages
-
How to find max(time) from table using group by
how to find max(time) from table using group by
select var max(time)
from table
into (var1, time1)
where .....
group by var.
it is fetching record which is top in table.
if u can help?
regards.No this will fetch the maximum time from teh table.
select var max(time)
from table xxxx
into (var1, time1)
where .....
group by var.
Refer this code
TABLES SBOOK.
DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.
DATA: CONNID LIKE SBOOK-CONNID.
SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT )
INTO (CONNID, COUNT, SUM, AVG)
FROM SBOOK
WHERE
CARRID = 'LH ' AND
FLDATE = '19950228'
GROUP BY CONNID.
WRITE: / CONNID, COUNT, SUM, AVG.
ENDSELECT. -
How to find out index from table?
Hi all,
I've tried to create indexes to some columns from some tables to use for Oracle Text.
I ve got a error message saying that I can not create an index:
"cannot create multiple domain indexes on a column list using same indextype".
I was wondering if an index already exists for that column, how do I find out the name of the index that points to that paticular colum?
Thanks a lot
E.Check the view dba_ind_columns
That will tell you.
something like;
select index_name, column_position, column_name from dba_ind_columns
where table_name = '<table name>'
order by 1,2 -
ASE 15.7 how to find data entry using table page nr
Hi,
I am looking for a dbcc () to get data when I know page number from a table
Thank youHi Isabella,
What your asking is not supported by SAP .. although you can achieve the result by using dbcc page:
http://wiki.scn.sap.com/wiki/display/SYBASE/DBCC+page
The only problem is that the data is in binary format so you have to format it by yourself to a readable format.
Regards,
Adam -
How to refine data in Aggregate tables in Oracle BI
Hello!
How to refine data in aggregates tables (created by "create aggregates ..." statement) after the data in corresponding database tables was updated?
It is unable to use the "delete aggregates" statement and then "create aggregates" again, because "delete aggregates" eliminates all aggregates in a model, but there are several aggregates in our model, that are intended for refining in different time moments and periods.
Thanks903830 wrote:
Hi folks,
suppose we have table emp01, have 10 records & we create another table emp02 as
create table emp02 as select * from emp01;
now both the table have identical data.
How to find "data" in two tables are identical?Why wouldn't they be identical? You've just created one table as a copy of the other. They are identical in data terms. -
How to find data dictionary and oracle schema tables for UTF8 char conversi
I am doing UTF8 char conversition, i got lot of convertable objects,as per document we don't need to worry about data dictionary objects and how to find data dictionary and oracle schema objects for UTF8 char conversition.
USER.TABLE Convertible Truncation Lossy
MDSYS.OPENLS_NODES 17 0 0
MDSYS.SDO_COORD_OP_PARAM_VALS 200 0 0
MDSYS.SDO_GEOR_XMLSCHEMA_TABLE 1 0 0
MDSYS.SDO_STYLES_TABLE 78 0 0
MDSYS.SDO_XML_SCHEMAS 3 0 0
ORDDATA.ORDDCM_CT_PRED_OPRD 51 0 0
ORDDATA.ORDDCM_DOCS 9 0 0
ORDDATA.ORDDCM_MAPPING_DOCS 1 0 0
SYS.METASTYLESHEET 178 0 0
SYS.REGISTRY$ERROR 2 0 0
SYS.RULE$ 21 0 0
SYS.SCHEDULER$_EVENT_LOG 182 0 0
SYS.WRH$_SQLTEXT 2,099 0 0
SYS.WRH$_SQL_PLAN 1,736 0 0
SYS.WRI$_ADV_ACTIONS 5,452 0 0
SYS.WRI$_ADV_DIRECTIVE_META 5 0 0
SYS.WRI$_ADV_OBJECTS 2,278 0 0
SYS.WRI$_ADV_RATIONALE 9,594 0 0
SYS.WRI$_ADV_SQLT_PLANS 455 0 0
SYS.WRI$_ADV_SQLT_PLAN_STATS 288 0 0
SYS.WRI$_DBU_FEATURE_METADATA 188 0 0
SYS.WRI$_DBU_FEATURE_USAGE 16 0 0
SYS.WRI$_DBU_HWM_METADATA 20 0 0
SYS.WRI$_REPT_FILES 27 0 0
XDB.XDB$DXPTAB 2 0 0
XML CSX Dictionary Tables:
USER.TABLE Convertible Truncation Lossy
Application Data:
USER.TABLE Convertible Truncation Lossy
APPLSYS.BISM_OBJECTS 4 0 0
APPLSYS.DR$FND_LOBS_CTX$I 0 103 1,260,883
APPLSYS.FND_CONC_PROG_ANNOTATIONS 272 0 0
APPLSYS.FND_OAM_CONTEXT_FILES 15 0 0
APPLSYS.FND_OAM_DOC_LINK 1 0 0
APPS.FND_OAM_CONTEXT_FILES_1 6 0 0
AZ.AZ_APIS 11 0 0
AZ.AZ_SELECTION_SET_ENTITIES_B 48 0 0
ECX.ECX_DTDS 205 0 0
ECX.ECX_FILES 91 0 0
IBC.IBC_ATTRIBUTE_BUNDLES 41 0 0
JTF.JTF_HEADER_DTD 1 0 0
JTF.JTF_MESSAGE_OBJECTS 82 0 0
JTF.JTY_TRANS_USG_PGM_SQL 29 0 0
ODM.ODM_PMML_DTD 1 0 0
OKC.OKC_REPORT_SQL_B 3 0 0
OKC.OKC_REPORT_SQL_TL 2 0 0
OKC.OKC_REPORT_XSL_TL 5 0 0
XDP.XDP_PROC_BODY 10 0 0
[Distribution of Convertible, Truncated and Lossy Data by Column]
Data Dictionary Tables:
USER.TABLE|COLUMN Convertible Truncation Lossy
MDSYS.OPENLS_NODES|SYS_NC00004$ 17 0 0
MDSYS.SDO_COORD_OP_PARAM_VALS|PARAM_VALUE_FILE 200 0 0
MDSYS.SDO_GEOR_XMLSCHEMA_TABLE|XMLSCHEMA 1 0 0
MDSYS.SDO_STYLES_TABLE|DEFINITION 78 0 0
MDSYS.SDO_XML_SCHEMAS|XMLSCHEMA 3 0 0
ORDDATA.ORDDCM_CT_PRED_OPRD|SYS_NC00004$ 51 0 0
ORDDATA.ORDDCM_DOCS|SYS_NC00005$ 9 0 0
ORDDATA.ORDDCM_MAPPING_DOCS|SYS_NC00007$ 1 0 0
SYS.METASTYLESHEET|STYLESHEET 178 0 0
SYS.REGISTRY$ERROR|MESSAGE 1 0 0
SYS.REGISTRY$ERROR|STATEMENT 1 0 0
SYS.RULE$|CONDITION 21 0 0
SYS.SCHEDULER$_EVENT_LOG|ADDITIONAL_INFO 182 0 0
SYS.WRH$_SQLTEXT|SQL_TEXT 2,099 0 0
SYS.WRH$_SQL_PLAN|OTHER_XML 1,736 0 0
SYS.WRI$_ADV_ACTIONS|ATTR5 2,726 0 0
SYS.WRI$_ADV_ACTIONS|ATTR6 2,726 0 0
SYS.WRI$_ADV_DIRECTIVE_META|DATA 5 0 0
SYS.WRI$_ADV_OBJECTS|ATTR4 2,278 0 0
SYS.WRI$_ADV_RATIONALE|ATTR5 9,594 0 0
SYS.WRI$_ADV_SQLT_PLANS|OTHER_XML 455 0 0
SYS.WRI$_ADV_SQLT_PLAN_STATS|OTHER 288 0 0
SYS.WRI$_DBU_FEATURE_METADATA|INST_CHK_LOGIC 21 0 0
SYS.WRI$_DBU_FEATURE_METADATA|USG_DET_LOGIC 167 0 0
SYS.WRI$_DBU_FEATURE_USAGE|FEATURE_INFO 16 0 0
SYS.WRI$_DBU_HWM_METADATA|LOGIC 20 0 0
SYS.WRI$_REPT_FILES|SYS_NC00005$ 27 0 0
XDB.XDB$DXPTAB|SYS_NC00006$ 2 0 0
XML CSX Dictionary Tables:
USER.TABLE|COLUMN Convertible Truncation Lossy
Application Data:
USER.TABLE|COLUMN Convertible Truncation Lossy
APPLSYS.BISM_OBJECTS|SYS_NC00023$ 4 0 0
APPLSYS.DR$FND_LOBS_CTX$I|TOKEN_TEXT 0 103 1,260,883
APPLSYS.FND_CONC_PROG_ANNOTATIONS|PROGRAM_ANNOTAT 272 0 0
APPLSYS.FND_OAM_CONTEXT_FILES|TEXT 15 0 0
APPLSYS.FND_OAM_DOC_LINK|DOC_LINK_INFO 1 0 0
APPS.FND_OAM_CONTEXT_FILES_1|TEXT 6 0 0
AZ.AZ_APIS|FILTERING_PARAMETERS 11 0 0
AZ.AZ_SELECTION_SET_ENTITIES_B|FILTERING_PARAMETE 48 0 0
ECX.ECX_DTDS|PAYLOAD 205 0 0
ECX.ECX_FILES|PAYLOAD 91 0 0
IBC.IBC_ATTRIBUTE_BUNDLES|ATTRIBUTE_BUNDLE_DATA 41 0 0
JTF.JTF_HEADER_DTD|HEADER_DTD 1 0 0
JTF.JTF_MESSAGE_OBJECTS|BUS_OBJ_DTD 41 0 0
JTF.JTF_MESSAGE_OBJECTS|BUS_OBJ_SQL 41 0 0
JTF.JTY_TRANS_USG_PGM_SQL|BATCH_DEA_SQL 1 0 0
JTF.JTY_TRANS_USG_PGM_SQL|BATCH_INCR_SQL 5 0 0
JTF.JTY_TRANS_USG_PGM_SQL|BATCH_TOTAL_SQL 6 0 0
JTF.JTY_TRANS_USG_PGM_SQL|INCR_REASSIGN_SQL 5 0 0
JTF.JTY_TRANS_USG_PGM_SQL|REAL_TIME_INSERT 6 0 0
JTF.JTY_TRANS_USG_PGM_SQL|REAL_TIME_SQL 6 0 0
ODM.ODM_PMML_DTD|DTD 1 0 0
OKC.OKC_REPORT_SQL_B|SQL_TEXT 3 0 0
OKC.OKC_REPORT_SQL_TL|HELP_TEXT 2 0 0
OKC.OKC_REPORT_XSL_TL|HELP_TEXT 2 0 0
OKC.OKC_REPORT_XSL_TL|XSL_TEXT 3 0 0
XDP.XDP_PROC_BODY|PROC_BODY 10 0 0
-------------------------------------------------- ---------------- ---------------- ----------------Hi;
Please run below query which could be helpful for your issue:
select * from dictionary where TABLE_NAME LIKE '%NLS%'
select * from dictionary where TABLE_NAME LIKE '%GLOBAL%'
Regard
Helios -
Hello,
How to find and remove obsolete table entries from below tables in EWM System.
/SAPAPO/MATKEY
/SAPAPO/MATMAP
/SAPAPO/MARM
/SAPAPO/MATLOC
/SAPAPO/MATMOD
/SAPAPO/MATRQ
/SAPAPO/MATLOTSZ
Thank you,
PravinPravin,
First, tell me how you determine that these entries are 'obsolete'.
Removing master data from SCM can usually be done using transaction WUF; however, you have to ensure that it is not re-sent to the SCM system, or you are just wasting your time.
Best Regards,
DB49 -
How do you delete records from table with data in a select option
how do you delete records from table with relevant to data in a select option..how to write coding
Hi,
Try
if not s_select_option [ ] is initial.
delete * from table
where field in s_select_option.
endif.
commit work.
Be careful though. If select option is emty, you will delete the entire table.
Regards,
Arek -
How to find the count of tables going for fts(full table scan in oracle 10g
HI
how to find the count of tables going for fts(full table scan) in oracle 10g
regardsHi,
Why do you want to 'find' those tables?
Do you want to 'avoid FTS' on those tables?
You provide little information here. (Perhaps you just migrated from 9i and having problems with certain queries now?)
FTS is sometimes the fastest way to retrieve data, and sometimes an index scan is.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9422487749968
There's no 'FTS view' available, if you want to know what happens on your DB you need, like Anand already said, to trace sessions that 'worry you'. -
Hi,
How to find the average of table row values it should display in next row in libwindow/CVI
Please let me know the solution.There isn't a built-in function to perform calculations on thable cells. What you can do is to retrieve thable cells values and calculate the average by yourself.
To retrieve a bunch of cells in a single instruction you can use GetTableCellRangeVals: prerequisite for this function to work correctly is that cells are all included in a Rect structure (shortly, a rectangle) and are all of the same data type. See the help for the function for some explanations and the link to an example of its usage. In Cell range parameter you can pass VAL_TABLE_ROW_RANGE (row) macro to retrieve an entire row. See here for details.
Once you have retrieved cell values in an array, you can pass it to Mean function to calculate the average.
Proud to use LW/CVI from 3.1 on.
My contributions to the Developer Zone Community
If I have helped you, why not giving me a kudos? -
How to find last accessed/updated tables and the query text?
I am using :
Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
How to find last accessed/updated tables and the query text?
Regards
LEE1212Check DBA_TBALES view there you find one date column that indicate last update
One option is as follows:
(1) Turn the auditing on: AUDIT_TRAIL = true in init.ora
(2) Restart the instance if its running.
(3) Audit the table:
AUDIT INSERT,SELECT,DELETE,UPDATE on TableName
by ACCESS WHENEVER SUCCESSFUL
(4) Get the desired information using :
SELECT OBJ_NAME,ACTION_NAME ,to_char(timestamp,'dd/mm/yyyy , HH:MM:SS')
from sys.dba_audit_object.
Cheer,
Virag Sharma
http://virag.sharma.googlepages.com/
http://viragsharma.blogspot.com/
Message was edited by:
virag_sh -
How to find the CRM related Tables form a Particular DataSource
Hi friends
<b>How to find the CRM related Tables form a Particular DataSource
of BusinessContent.</b>
ex: i had taken CRM - DataSource ........ 0CRM_LEAD_H (Lead Header Data)
for this DS i assign IS and extract data. But i want to Know from which
CRM tables it was comming.
ie ..I want to know the what tables linked to Datasource(0CRM_LEAD_H)
How it has to check?Just for your info, you can find as useful (for a methodology to solve this kind of issue) this weblog:
SAP BW and Business Content Datasources: in pursuit of the origins
Hope it helps!
Bye,
Roberto -
How to get Date Format from Local Object.
Hi All,
I am new to Web Channel.
I need to know Date format From date of locale.
suppose there is a date "01/25/2010" date in date field I want to get string "mm/dd/yyyy". Actually I have to pass date format to backend when I call RFC.
Is there any way to get Date format from "Locale" object. I should get date format for local object
I get local object from "UserSessionData" object but how to get Date format from it.
I am not looking for Date value. I am looking for current local date format ("mm/dd/yyyy or dd/mm/yyyy or mon/dd/yyyy) whatever local date format. I could not find example which show how to get date format from "Locale" object.
Any help will be appreciated with rewards.
Regards.
Web ChannelHi,
You can get it from "User" or "Shop" business object.
Try to get User or Shop Business Object as shown below.
BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);
User user = bom.getUser();
char decimalNotation = user.getDecimalPointFormat().getGroupingSeparator();
If you are seeing "1,234.00" then above code will return "."
I hope this information help you to resolve your issue.
eCommerce Developer. -
How to hide a field from table maintenance view?
Hi,
How to hide a field from table maintenance view?
The field is used for data created date. I need to hide it from display.
ThanksChk this link.
http://help.sap.com/saphelp_nw04/helpdata/en/66/33f52010dd11d6999300508b5d5211/frameset.htm
Maintenance Attributes
You can assign a maintenance attribute P to individual fields in the maintenance view definition in the Dictionary (SE11). It can be H (hidden)
H (hidden)
A field flagged H is not displayed on the screen. This field must also be filled in the background by a routine at an event.
The system writes R and H fields to the database like all other fields when a new data record is saved. -
How to Find out the all tables in module wise ?
Dear Friends,
1.How to Find out the all tables in module wise ?
what are the total number of table in SAP ?
2. how to find out all existing functions in SAP ?
Thanks and regards,
Subasha Chandra Sahoo.Hi,
You will get the module wise list from:
http://www.sourceveda.com/SAPReference.htm
http://www.sourceveda.com/
Regards...
Maybe you are looking for
-
On a HP Officejet Pro L7780 All-in-One printer, is there a toner and where is it?
On a HP Officejet Pro L7780 All-in-One printer, is there a toner and where is it located? I've looked in Products and Supplies and don't see it but my printer is saying that it's low or empty.
-
I can't see the library option in the window drop down in photoshop cc
I'm trying to use the new Libraries panel in Photoshop CC (Window > Library) For some reason it it isn't showing in the drop down Any ideas why not
-
Short dump during select statement
hi, i have to display 1 alv list output using REUSE_ALV_HIERSEQ_LIST_DISPLAY function module...so i have populated the data using select statement select EXIDV brgew meabm vegr1 erlkz vhilm erdat aenam ernam from vekp
-
cannot send e-mail over mobile broad band from ipad
-
Use trial version of elements 9 with elements 8 installed
I have Premiere Elements 8 installed. It hangs after a Peak file is created. It does this everytime, in three different computers and in both XP and Windows 7! I am able to run Elements 8 for about 3 to 3 1/2 minutes before it hangs. I would like to