Creating a ad-hoc calculation using sql query
Hi All,
I want to know if its possible some way to create a ad-hoc sql query inside a workbook so as to create a calculation using that sql.
I have a folder which gives me balance for any period. My requirement is to display current period balance along with prior years closing balance in same record for each code combination. I dont want to modify folder definition.
Thanks for your inputs.
Vishal.
You could try creating a custom function for this purpose. You would need to register the function in the End User Layer and then you can call the function from your report.
Similar Messages
-
Hi All,
I am using Oracle Database Version 11.2.
I have a formula (A-B)/[(A-B)/10]. The tables that are holding the rows for this calculations are given below:
ROWS_TAB
====== ===================
Row Amount
====== ===================
A 5000
B -5000
FORMULA_TAB
======== =========== ======== =============
| ROW# | Operator | ROW | CONSTANT |
======== =========== ======== =============
| 10 | E | A | |
| 20 | - | B | |
| 30 | E | A | |
| 40 | - | B | |
| 50 | / | | 10 |
| 60 | / | | |
======== =========== ======== =============
The operator E starts a new calculation. The above formula has two sub-expressions thereby the table has two rows with E. Minus denoted by -, Plus denoted by +, Multiply denoted by *, and Division denoted by /.
I want to write single SQL query to perform this calculation. Is it achievable in SQL?
The scripts used to generate the tables are as below:
create table ROWS_TAB
(row_name VARCHAR2(1),
amount NUMBER);
create table FORMULA_TAB
(row# NUMBER,
operator VARCHAR2(1),
row_name VARCHAR2(1),
constant NUMBER);
INSERT INTO ROWS_TAB VALUES('A', 5000);
INSERT INTO ROWS_TAB VALUES('B', -5000);
INSERT INTO FORMULA_TAB VALUES(10, 'E','A',null);
INSERT INTO FORMULA_TAB VALUES(20, '-','B',null);
INSERT INTO FORMULA_TAB VALUES(30, 'E','A',null);
INSERT INTO FORMULA_TAB VALUES(40, '-','B',null);
INSERT INTO FORMULA_TAB VALUES(50, '/','',10);
INSERT INTO FORMULA_TAB VALUES(60, '/','','');
Can anyone help in writing SQL query....
Thanks in advance
Best Regards
BilalAs Frank said, it would be much easier to simply input the formula. Then, assuming you have OLAP option:
variable formula varchar2(30)
exec :formula := '(A-B)/((A-B)/10)';
with t as (
select *
from rows_tab
model
dimension by(row_number() over(order by row_name) r)
measures(
row_name,
amount,
count(*) over() cnt,
cast(:formula as varchar2(4000)) formula
rules(
formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
select :formula || ' = ' || dbms_aw.eval_number(formula) result
from t
where r = cnt
RESULT
(A-B)/((A-B)/10) = 10
SQL>
And if you do not have OLAP, you could use xquery:
with t as (
select *
from rows_tab
model
dimension by(row_number() over(order by row_name) r)
measures(
row_name,
amount,
count(*) over() cnt,
cast(:formula as varchar2(4000)) formula
rules(
formula[any] order by r = replace(nvl(formula[cv() - 1],formula[cv()]),row_name[cv()],amount[cv()])
select :formula || ' = ' || xmlquery(replace(formula,'/',' div ') returning content) result
from t
where r = cnt
RESULT
(A-B)/((A-B)/10) = 10
SQL>
SY. -
Help Required -- Can we use SQL Query to READ data from SAP MDM Tables
Hi All,
Please help.........
Can we use SQL Query to READ(No Creation/Updation/Deletion just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
Thanks in Advance
RegardsAll the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
BR,
Alok -
Information about constraints by using SQL query?
Hi
how can we view all the definition of a constraint by using SQL query.
Suppose I create following tables:
CREATE TABLE supplier
( supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
contact_name varchar2(50),
CONSTRAINT supplier_pk PRIMARY KEY (supplier_id, supplier_name)
CREATE TABLE products
( product_id numeric(10) not null,
supplier_id numeric(10) not null,
supplier_name varchar2(50) not null,
CONSTRAINT fk_supplier_comp
FOREIGN KEY (supplier_id, supplier_name)
REFERENCES supplier(supplier_id, supplier_name)
ON DELETE CASCADE
e.g. CONSTRAINT fk_supplier_comp: Plz write me the SQL query that tells that this is a FOREIGN KEY (supplier_id, supplier_name) and REFERENCES supplier(supplier_id, supplier_name) .....etc.
thanksYou mean "What is an Oracle Metalink?"
Then, Oracle Metalink (www.metalink.oracle.com) is an official web site of Oracle Corporation. This is the area where you can get an ultimate and immediate fixes for any sort of Oracle/Issues/Problems. And also, Patches/fixes/Notes/Procedures can be used as reference and can be downloaded from this.
Note: Sharing of Oracle Metalink information/credentials is highly illegal act.
Fore more information and benefits on Oracle Metalink, please take a look at the below URL.
http://www.oracle.com/support/premier/metalink.html
Regards,
Sabdar Syed. -
Build essbase cube using Sql query.....
Hi Team, Can we build dimensions as well as load data into essbase cubes using sql query generated from cognos cube. If so , please guide me the procedure
I'm not sure about cognos, if you can create an ODBC connection you can try using that in SQL load rules and see if that works.
Opening an SQL Database
Regards
Celvin
http://www.orahyplabs.com -
ReportViewer using SQL Query error states: Incorrect syntax near ','.
Hello Community
Using Visual Studio 2008 and SQL Server 2008 I created a Windows Application
that uses SQL Server Reporting Services. The application uses ReportViewer and
calls a method written using SQL query.
1-First I created the form.
2-Next I dragged the ReportViewer (Toolbox) and Table (from DataSource) onto the form.
The problem is that when it reaches the last line of the SQL query (ie, da.Fill(ds, "TableOne");)
the code fails stating the error message:
"Incorrect syntax near ','."
The following is the code behind the form containing the query:
private void ReportPgm1_Load(object sender, EventArgs e)
// TODO: This line of code loads data into the 'ReportDBDataSet.TableOne' table. You can move, or remove it, as needed.
this.TableOneTableAdapter.Fill(this.ReportDBDataSet.TableOne);
reportViewer1.ProcessingMode = ProcessingMode.Local;
LocalReport ReportOneLocalReport = reportViewer1.LocalReport;
DataSet ds = new DataSet("ReportDBDataSet.TableOne");
pgmReportOne(FromDate, ToDate, ds);
ReportDataSource ds = new ReportDataSource("ReportDBDataSet.TableOne");
ds.Value = dataset.Tables["TableOne"];
ReportOneLocalReport.DataSources.Clear();
ReportOneLocalReport.DataSources.Add(ds);
this.reportViewer1.RefreshReport();
private void pgmReportOne(DateTime FromDate, DateTime ToDate, DataSet ds)
SqlConnection connection = new SqlConnection("Data Source=ReportDBServer;Initial Catalog=ReportDB;Uid=sa;pwd=Password");
string sqlReportOne = "Select ([InDate], [FirstName], [LastName], [AGe]" +
"from TableOne";
SqlCommand command = new SqlCommand(sqlReportONe, connection);
command.Parameters.Add(new SqlParameter("paramFDate", FromDate));
command.Parameters.Add(new SqlParameter("paramTDate", ToDate));
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(ds, "TableOne");
Why does the last line throw an error?
Thank you
Shabeaut--NOTE: The statement below cannot be run on SQL Server 2012
--If you have an earlier version and can set the compatibility
--level to 80, it can be run.
SELECT sso.SpecialOfferID, Description, DiscountPct, ProductID
FROM Sales.SpecialOffer sso,
Sales.SpecialOfferProduct ssop
WHERE sso.SpecialOfferID *= ssop.SpecialOfferID
AND sso.SpecialOfferID != 1
Hi Scott
The *= is old syntax and not compatible with SQL Server 2012 (as stated in the comments).
You could do something like this instead
SELECT sso.SpecialOfferID
,Description
,DiscountPct
,ProductID
FROM Sales.SpecialOffer sso
left outer join Sales.SpecialOfferProduct ssop on sso.SpecialOfferID = ssop.SpecialOfferID
WHERE sso.SpecialOfferID != 1 -
Hi,
i need to load the data using sql query in to essbase cube by using maxl .If any one knows this please let me know.
i
thanks in advanceHere is a sample maxl script I use to clear, load, and calculation a BSO Application and Database. Both the Application and Database are titled "STAT_2".
/*** Login to essbase server ***/
/*** login $1 $2 on $3; ***/
login 'username 'password' on 'server';
/*** Set output file to spool all error messages only ***/
spool stdout on to 'C:\Hyperion\Automation\Logs\STAT_2_ALL_Load_Essbase.LOG';
spool stderr on to 'C:\Hyperion\Automation\Errors\STAT_2_ALL_Load_Essbase.ERR';
/*** Clear data in STAT_2 ***/
/** execute calculation 'STAT_2'.'STAT_2'.'ClrA2Yr'; **/
/*** Import data from the FACT_STAT_2YEARS table using a load rule ***/
import database 'STAT_2'.'STAT_2' data connect as 'SQLUserName' identified by 'SQLPassword' using server rules_file 'LdA_All.rul' on error write to 'C:\Hyperion\Automation\Logs\STAT_2_ALL_Load_Essbase.log';
/*** Calculate data in STAT_2 ***/
/** execute calculation 'STAT_2'.'STAT_2'.'ClcA2Yr'; ***/
spool off;
logout;
exit; -
Retreving Hexadecimal Values from a table using SQL query.
Hi,
I'm looking for a query to retreive Hexadecimal values contained in a column using SQL query.
The column contains the values of all types, alphanumeric, numeric and hexadecimal.
I need to retreive only hexadecimal values.
any help to me in this regard will be appreciated.
ThanksPresumably, you can be sure that any valid hex value is indeed MEANT to BE a hex value. For example the value 'ACE' is meant to be a hexadecimal value and not the word.
-
How to get tax break up of TDS using SQL query ?
Hi all,
We are developing a TDS report using SQL query
Report will contain VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount,
Bill Value 100.000,
TDS (2%) - 2.000,
TDS Surcharge(10% on TDS) - 0.2,
TDS Cess(2%(TDS+TDS Surcharge)) - 0.044,
TDS HeCess(1%(TDS+TDS Surcharge)) - 0.022.
We have developed this report which displays upto
VendorCode,Date(ap inv date),Vendor name,
Bill value,TDS Amount.
How to show tax break up of TDS in SQL query ?
Thanks,
With regards,
Jeyakanthan.Hi gauraw,
Thank for your reply.
I modified the query , pasted the query
as below in query generator,
Select T0.DocNum,T0.DocDate,T0.CardCode as 'Ledger',T1.TaxbleAmnt As 'Bill value',T1.WTAmnt as 'TDSAmt',(TDSAmt * 0.1) as 'TDS_Surch',
(((TDSAmt0.1) + TDSAmt)0.02) as 'TDSCess',
(((TDSAmt0.1) + TDSAmt)0.01) as 'TDSHCess'
FROM OPCH T0 INNER JOIN PCH5 T1 ON T0.DocEntry = T1.AbsEntry
WHERE (T0.DocDate >= '[%0]' and T0.DocDate <= '[%1]')
on clicking execute its showing error message invalid column
name 'TDSAmt'.
With regards,
Jeyakanthan -
How to retrive the blob data from a table using sql query
Hi gurus,
I have a table which has " BLOB "content in a column .I want to view the data From BLOB column using sql query .It would be helpfull If some one share their idea.
Regards,
vardhani.You can use data templates.
See this: http://blogs.oracle.com/xmlpublisher/entry/blob_clob_raw_and_looooong
http://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
Thanks,
Bipuser -
How to use sql query in java ?
i don't know how to use sql query in java code.
who can give me some advice?
thankshttp://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/
-
hi i am face with problem that is i want to show the how much approximate space required for backup or .bak file to get backup using sql query because i want to show the required memory for backup file on my java application
Hi FIROZ
TENNALI
Is this still an issue, or can we close the thread?
* closing a thread by marking the answer/s (there is a link beneath each response) and you can vote for useful responses as well (there is a link to vote on the left of each response)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
How to Use SQL Query having IN Clause With DB Adapter
Hi,
I am using 11.1.1.5 want to find out how to Use SQL Query having IN Clause With DB Adapter. I want to pass the IN values dynamically. Any ideas.
Thanksinvoke a stored procedure, it's safer than trying to put together an arbitrary SQL statement in the JCA adapter
-
Using SQL query on user defined table
Hi all,
i'am currently working on a project which use user defined table and i would like to know if sap allow us to do insertion/deletion/update on those table using sql query or if we have to use the DI only?
thanks
Best regards,Hi,
Definitely you can insert in UDT. You can update but you cant change the Code field after added the rest of the field
can be updated. You cant delete in UDT but you cant delete anytime in SQL Management Studio.
THanks.
CLint -
How to numberformat when using sql:query alogn with c:forEach JSTL tags
Is there anyway to format the numeric values returned from the database when using <sql:query> alogn with <c:forEach> tags
Here is my jsp code
<sql:query..../>
<c:forEach var="row" items="${queryResults.rows}">
<tr>
<td><c:out value="${row.COL1}" /></td>
<td><c:out value="${row.COL2}" /></td>
</tr>
</c:forEach>
Col1 values are numeric without any formats Eg: 1000, 10000, 1000000 etc.
how can i format them to 1,000 , 10,1000 , 100,000 etcIt is polite to mention what your answer was. These posts are not just here for you to ask questions, but to be used as a resource for other people to find answers. Saying "I solved it" with no details helps noone.
I presume you discovered the JSTL <fmt:formatNumber> tag?
Maybe you are looking for
-
How do I install new software updates on my mac?
my itunes and iphoto keep telling me I need a software update and I try to click on the software update button on the top left screen and it tells me to "install and restart" when I click that it JUST restarts and wont install anything. How do I upda
-
Problem calling ejb in oas from non-oracle java client
I am trying to call an ejb that is deployed in OAS 9i from a java server page running another non-Oracle app server. I continue to get the following error: java.lang.ExceptionInInitializerError: org.omg.CORBA.INITIALIZE: can't instantiate default ORB
-
I am not clear wen should we use the SOAP adapter and wat all about the Webservice.I am new to XI .Can anyone help me.????
-
It says I cannot reconfigure my router to MAC OS X 10.9.4 but it can do so with a MAC OS X 10.5.8, MAC OS X 10.6.1, and/or a MAC OS X 10.7 or later operating system. How is it even possible that my MAC OS X 10.9.4 is later than MAC OS X 10.7 model bu
-
Hi all. I'm trying to get a Resource self de-provisioned from users, but I'm not able to reach this goal. The resource I'm using is without connectors, it is only a logical resource. Note that I've created approval policies to get auto approved (both