How to perform Excel like function in Sql
TABLE_NAM ROWS_IMPACTED_ACTUAL OPERATION_TIMESTAMP TIME_ELASPED
END_OF_DAY 0 06-SEP-12 04.37.18.328927000 PM
TAXL 0 06-SEP-12 04.37.18.337675000 PM
TRANSACTION 0 06-SEP-12 04.37.18.430409000 PM
PORTFOLIO 0 06-SEP-12 04.37.18.430984000 PM
I have a table similar to the one above, how do i get time elasped above , for each operation?
That is how long each table completed an operation.
Thanks
Edited by: user8375449 on Sep 14, 2012 4:09 AM
No, you cannot attach documents/picture to the forums, that's just not possible (this isn't Oracle Support which you pay for)
If you read the FAQ that I linked to, it tells you how to post code and data using the {noformat}{noformat} tags.
Similar Messages
-
How to implement Excel like functionality using Table?
I have a requirement to implement excel like functionality in a table, i.e when I update the amount in the first row and tab out, the values in the rows below should get affected.
Could any one suggest idea how to get this done?Hi Timo,
Thanks for your Reply.
Can you please provide the code for capturing the key stroke in java script and queue it in the server and calling only the adf data table values from it.
Thanks And Regards,
Lovenish Garg
Edited by: lovenish on 21-Jan-2011 04:25 -
How to Perform an Aggregate Function?
Hi,
I'm trying to define in Designer 6.5 an object with the following select: (example)
sum (count (distinct REPORTING.table.object_name))
the SQL parsing restitues me this error --> "The SQL can not perform an aggregate function on an expression containing an aggregate or a subquery".
Can anyboby explain me the problem and above all how to solve it?
Thanks
RiccardoHi,
You cannot mix different aggregations functions in the same SQL expression: this is a SQL limitation for all databases.
You need to use subselect to achieve your requirement.
See the following example that works on SQL Server:
Select sum(a._count) from
(Select count (distinct cust_id) as _count from Club.dbo.Customer) a
Regards,
Didier -
How to get Excel to function like InfoPath with SharePoint libraries?
When working with InfoPath, there is a way to promote fields from your form to a SharePoint Library so that when you submit the form, it submits the actual form and the metadata from the fields in the form to columns in the document library in SharePoint.
Well, I'm trying to accomplish this with Excel, but am so used to doing it with InfoPath I'm running into a lot of walls. I've found an add-in that allows me to insert a table and publish/sync it to a library in SharePoint, so that data from that table is
sent to the library.
Trouble is, I need the spreadsheet to also be "submitted" to the library so I can send it to specific users based on a workflow. So basically, I need metadata from the form to be sent to the library for the purpose of triggering the workflow so that
it routes the spreadsheet to the correct user. But in order for it to route (or provide a link to the spreadsheet in the workflow email) the sheet, it also needs to get submitted to the library.
So I'm trying to get InfoPath functionality out of this.Excel does not integrate with SharePoint like that. Is there a reason you're dealing with entire spreadsheets instead of converting them to lists and/or using InfoPath for form purposes?
SharePoint Architect || Microsoft MVP ||
My Blog
Planet Technologies ||
SharePoint Task Force
Actually, it does. You can promote fields from Excel, InfoPath, etc. to SharePoint and use them to do exactly what I was looking to do above. I actually did this for a huge project and it worked.
And yes, the Excel spreadsheets have an addin that is required for the business process on the client side. -
Implementing Pivot Table like functionality using SQL
Dear All,
Please access a online document:
http://docs.google.com/View?docid=dhntd3vh_0gmwgmq
A 'query-output' is given.
I have pasted this output in Excel and using it's Pivot table feature
obtained an output given as 'Expected-Output' in the document.
How can I achieve this using SQL?
Any guidelines are most welcome.
-SameerSee if this implementation could satisfy your needings.
CREATE THE A TABLE WITH ESSENTIAL INFORMATION
CREATE TABLE THINGS (
WHO VARCHAR2(32) NOT NULL,
WHAT VARCHAR2(32) NOT NULL,
NUM NUMBER
FILLING THE ESSENTIAL INFORMATION
INSERT INTO THINGS VALUES ('AFAS','TRANSACTION',4);
INSERT INTO THINGS VALUES ('FAS-AP','TRANSACTION',2);
INSERT INTO THINGS VALUES ('FAS-AR','TRANSACTION',2);
INSERT INTO THINGS VALUES ('FAS-GL','MASTER',3);
INSERT INTO THINGS VALUES ('FAS-GL','REPORT',5);
INSERT INTO THINGS VALUES ('INTERNATIONAL CARGO','MASTER',1);
INSERT INTO THINGS VALUES ('INTERNATIONAL CARGO','REPORT',2);
INSERT INTO THINGS VALUES ('INTERNATIONAL CARGO','TRANSACTION',9);
INSERT INTO THINGS VALUES ('PACKAGE EXPRESS','INTELLIVIEW REPORT',1);
INSERT INTO THINGS VALUES ('PACKAGE EXPRESS','MASTER',4);
INSERT INTO THINGS VALUES ('PACKAGE EXPRESS','TRANSACTION',76);
INSERT INTO THINGS VALUES ('PACKAGE EXPRESS','UTILITIES',1);
INSERT INTO THINGS VALUES ('WAREHOUSE','REPORT',1);
INSERT INTO THINGS VALUES ('WAREHOUSE','TRANSACTION',9);
CREATE A TABLE FOR THE FULL CORRISPONDENCE
CREATE TABLE THINGS2 AS
SELECT A.WHO,B.WHAT, 0 NUM
FROM (
SELECT DISTINCT WHO
FROM THINGS
) A, (
SELECT DISTINCT WHAT
FROM THINGS
)B;
SET THE RIGHT VALUES ON EACH ROW
UPDATE THINGS2 A
SET NUM = (
SELECT NVL(SUM(NUM),0)
FROM THINGS B
WHERE ( A.WHO = B.WHO )
AND ( A.WHAT = B.WHAT )
SHOW THE FULL TABLE ( FULL BECAUSE IT CONTAINS THE FULL JOIN BETWEEN "WHO" AND "WHAT" )
SELECT *
FROM THINGS2
RETRIVE THE EXPECTED OUTPUT
SELECT A.WHO,"TRANSACTION","MASTER","INTELLIVIEW REPORT","UTILITIES"
FROM (
SELECT WHO,NUM "TRANSACTION"
FROM THINGS2
WHERE WHAT = 'TRANSACTION'
) A,(
SELECT WHO,NUM "MASTER"
FROM THINGS2
WHERE WHAT = 'MASTER'
) B,(
SELECT WHO,NUM "REPORT"
FROM THINGS2
WHERE WHAT = 'REPORT'
) C,(
SELECT WHO,NUM "INTELLIVIEW REPORT"
FROM THINGS2
WHERE WHAT = 'INTELLIVIEW REPORT'
) D,(
SELECT WHO,NUM "UTILITIES"
FROM THINGS2
WHERE WHAT = 'UTILITIES'
) E
WHERE ( A.WHO = B.WHO )
AND ( A.WHO = C.WHO )
AND ( A.WHO = D.WHO )
AND ( A.WHO = E.WHO );
Ps.
Could anybody tell me how is it possible to indent text on the board of this forum?
Bye Alessandro -
How to read stored procedure/function in SQL*PLUS?
I created procedure and stored in Oracle. Now, I want to read it or may be modify it.
I know "Oracle Enterprise Manager" can make it, but if I don't have it, how can I achieve it?
I don't want to use "CREATE OR REPLACE PROCEDURE ..." because I need to read it first. How can I do?
Thanks!!!
Anne<BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Anne:
I created procedure and stored in Oracle. Now, I want to read it or may be modify it.
I know "Oracle Enterprise Manager" can make it, but if I don't have it, how can I achieve it?
I don't want to use "CREATE OR REPLACE PROCEDURE ..." because I need to read it first. How can I do?
Thanks!!!
Anne<HR></BLOCKQUOTE>
Anne -
On SQLPLUS use follwings -
Set long 50000 ;
Spool procname.txt
and then write the SQL query which was given
in earlier reply.If You u have problem let us know.
Thanks
Ajeet
null -
How to perform Descending Order function on a DATE column in Analytical View
Hi,
I have the below requirement
For the article/site having a+ stock quantity from table MARD field LABST, check the last goods movement date as a receipt table MSEG field SHKZG value "H". To get this information fetch the data from the table MSEG & MKPF. The lead time from that date till the present date is the ageing information. Show the output sorted on the duration as ageing information.
Created a calculate column with the below code and it is populating data i.e. multiple records for the same item for different dates like
daysbetween(date("BUDAT"),date("CURRENT_DATE"))
MC25001;1001;08;DC01;;H;WL;20150317;20150317;000000000000000233;2015-04-20;34;1,003
MC25001;1001;08;DC01;;H;WL;20150312;20150312;000000000000000233;2015-04-20;39;2,006
MC25001;1001;08;DC01;;H;WL;20141203;20141203;000000000000000233;2015-04-20;138;3,009
MC25001;1001;08;DC01;;H;WL;20150409;20150409;000000000000000233;2015-04-20;11;1,003
MC25001;1001;08;DC01;;H;WL;20141201;20141201;000000000000000233;2015-04-20;140;1,003
Now I have to sort the date (BUDAT) (highlighted in bold above) to be sorted in Descending and then take the first record and then apply the the above formula to get the aging stock.
Any suggestions?
Best Regards,
VijayaHi,
But I don't think you need to go for scripting view. What you can do here is create one more calculation view , insert this analytical view in the projection and select date as measure and pick max value and then create one calculated column and put your logic.
I hope i got your requirement correctly.
BR
Sumeet -
How to perform grouping like a daisy chain
Hi:
I have a database table of Building Inspections (InspectionID) for each Building Permit (PermittingID). Sometimes the inspections fail and have to be re-inspected. I do not relate each re-inspection to the original inspection. I relate each re-inspection
to the inspection being re-inspected. I am using daisy chain logic.
For example:
PermittingID InspectionID ReinspectionRequestNum InspStatus
3 3591
F
3 3843
3591 F
3 4437
3843 F
3 4777
4437 F
3 5069
4777 F
3 5204
5069 F
3 5242
5204 F
I have been asked to create a report of ONLY the inspections/re-inspections that have failed and continue to fail (like above example). This includes any inspections that failed and were never reinspected.
For example:
PermittingID InspectionID ReinspectionRequestNum InspStatus
17 8
F
17 11
F
17 16
F
17 236
F
17 237
F
17 238
F
I must Exclude any inspections that have failed, but ultimately passed.
For example I would exclude ALL below:
PermittingID InspectionID ReinspectionRequestNum InspStatus
105 38
F
105 76
38 P
PermittingID InspectionID ReinspectionRequestNum InspStatus
3 3480
F
3 3669
3480 F
3 3942
3669 P
Any help is greatly appreciated with a query to filter out all inspections that have eventually passed.
Thank you.
CarmelitaHi CKCOMPUTER,
Regarding your description, are you trying to exclude the records which has the 'P' InspStatus? I am confused by the last sample with the PermittingID 3, I noticed that at the very above the records with 3 were mentioned not being excluded. If that
is a typo, you may reference the below query to achieve your requirement.
CREATE TABLE BuildingInspection(PermittingID INT,InspectionID INT,ReinspectionRequestNum INT,InspStatus CHAR(1));
INSERT INTO BuildingInspection VALUES(3,3591,NULL,'F');
INSERT INTO BuildingInspection VALUES(3,3843,3591,'F');
INSERT INTO BuildingInspection VALUES(3,4437,3843,'F');
INSERT INTO BuildingInspection VALUES(3,4777,4437,'F');
INSERT INTO BuildingInspection VALUES(3,5069,4777,'F');
INSERT INTO BuildingInspection VALUES(3,5204,5069,'F');
INSERT INTO BuildingInspection VALUES(3,5242,5204,'F');
INSERT INTO BuildingInspection VALUES(17, 8 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(17, 11 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(17, 16 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(17, 236 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(17, 237 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(17, 238 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(105, 38 ,NULL,'F');
INSERT INTO BuildingInspection VALUES(105, 76 ,38,'P');
SELECT * FROM BuildingInspection BI WHERE NOT EXISTS(SELECT 1 FROM BuildingInspection WHERE InspStatus='P' AND PermittingID=BI.PermittingID );
DROP TABLE BuildingInspection;
If the records with 3 are in the same table with the 3s above, please clarify the correlation.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
How to perform Steps to integrate AXL SQL Toolkit with CUCM
Steps to integrate AXL SQL Toolkit with CUCM
Here you go:
https://www.google.com/search?q=javasqltoolkit+site%3Anetcraftsmen.net&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a#q=java+sql+toolkit+site:netcraftsmen.net&rls=org.mozilla:en-US:official&safe=images&spell=1
Anthony Holloway
Please use the star ratings to help drive great content to the top of searches. -
Call C function in SQL statement
dear all
I want to know how i can call C function in SQL statement where clausehttp://asktom.oracle.com/pls/ask/f?p=4950:8:80100593788949622::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:934029542973
-
How to perform operations on table control
hello experts,
will u plz tell me how to perform operations like delete and update on tablecontrol in module pool.
thanks in advance,Hey Aravind,
In case you want to delete just from your table control and not from database table, then you can use the commands:
clear <workarea_name>
delete <workarea_name>
for your selected rows.
And for deleting from database tables also, use:
Delete from <Database_table_name> where <where_clause>.
clear <workarea_name>
delete <workarea_name>
This will delete both from the table control and database table also.
Reward if it proved useful to you.
Regards
Natasha Garg -
Execute a function in SQL Worksheet
How can I execute a function in SQL Worksheet.
The function takes in two parameters of type varchar2 and returns a boolean.
the syntax is:
set serveroutput on
VARIABLE x BOOLEAN;
EXECUTE :x := check_number('78','A');
PRINT x ;
my error is:
SP2-0552: Bind variable "X" not declared.
I have also tried:
set serveroutput on
select check_number('78','A')
from dual;
my error is:
ERROR at line 1:
ORA-06552: PL/SQL: Statement ignored
ORA-06553: PLS-382: expression is of wrong type
thanks.You could even cut out the variable:
SQL> CREATE OR REPLACE FUNCTION is_true
2 ( p1 VARCHAR2
3 , p2 VARCHAR2 )
4 RETURN BOOLEAN
5 AS
6 BEGIN
7 RETURN p1 = p2;
8 END is_true;
9 /
Function created.
SQL> exec dbms_output.put_line(sys.diutil.bool_to_int(IS_TRUE('x','y')))
0
PL/SQL procedure successfully completed.
SQL> exec dbms_output.put_line(sys.diutil.bool_to_int(IS_TRUE('x','x')))
1
PL/SQL procedure successfully completed. -
How to create a dynamic multi-line function in SQL Server
I am attempting to create a Multi-Line Function in SQL Server that accepts a dynamic WHERE clause as a parameter. I need this so that the function can be as versatile as possible for the filter that needs to be applied. I am unfortunately getting an error
upon creation of the function. I don't know how to solve the problem. Can someone advise me?
SQL:
SET
ANSI_NULLSON
GO
SET
QUOTED_IDENTIFIERON
GO
-- =============================================
-- Author:
-- Create date: 2/3/2014
-- Description: This multiline function will accept a generic WHERE Clause and apply it to the query for return.
-- =============================================
CREATE
FUNCTIONTESTMULTILINEFUNCTION
@WHEREvarchar(1024)
,@CHANGEDDATEasdatetime
RETURNS
@TESTTABLE
TABLE
IDint
,REVint
AS
BEGIN
Declare@SQLSTRINGvarchar(4096)
SET@SQLSTRING=''
SET@SQLSTRING=@SQLSTRING+'SELECT
REVS.ID, REVS.Revision
FROM
Select distinct result.ID, Max(Rev) as ''''Revision''''
FROM
Select * from dbo.BugsAll
where
[Changed Date] < @CHANGEDDATE
) result
GROUP BY result.ID
) REVS
join dbo.BugsAll BA on (BA.ID=REVS.ID AND BA.REV=REVS.revision)'
IF
(@WHEREisnotnullOR@WHERE<>'')
BEGIN
SET@SQLSTRING=@SQLSTRING+'
WHERE '+@WHERE;
END
INSERT@TESTTABLE
EXEC
(@SQLSTRING)
RETURN
END
GO
ERROR:
Msg 443, Level 16, State 14, Procedure TESTMULTILINEFUNCTION, Line 44
Invalid use of a side-effecting operator 'INSERT EXEC' within a function.
Senior Test Lead -- Microsoft>> Unfortunately I really need to form a dynamic query in a table valued function on the SQL SERVER. I have another tabled valued function that needs something returned as a table in order to further join the data. I am not allowed to use Stored
Procedures in that function. <<
You do know that real SQL programmers hate the proprietary nightmare of tabled valued functions? This is how you procedural programmers avoid learning set-oriented declarative and functional programming.
Your mindset wants to write to a scratch tape or disk file (aka “tabled valued function result table”) just like you did BASIC, FORTRAN or COBOL. QL programmers do not have to materialize their data. We can use VIEW or a drive table as well as a base table.
>> Plus, there are occasions where I don't want to pass in a field [sic: columns are not fields] parameter or need to change a parameter list such that I don't wish the table function to filter by a particular field [sic] or other setting. <<
What you want is a magical “Automobiles, Squids and Lady Gaga” function. An SQL programmer might write a complex VIEW then do simpler SELECTs off it.
>> My application pushes the WHERE clause from EXCEL to SQL to do the hard work as EXCEL is not the application in which I want to process the SQL statement and pass it via ODBC. I cannot run macros in Excel on the web.<<
This is a crazy language system. Usually we fetch data in SQL and then pass it to a math package, report writer, etc. We never keep logic (aka WHERE clauses) outside the database.
>> I am bummed about the fact that this feature doesn't work. It will up my server management costs to maintain unique tabular based functions based on WHERE clause query <<
So stop writing those “tabular based functions”, change your mindset and start learning SQL and do it right.
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How to use LIKE function with a parameter in Oracle REPORT builder??
how could i use parameter inside a LIKE function in Oracle reports builder?
it works in SQL plus, but not in report builder!!
Example:
select code,desc from item_master where desc
like '%&give_desc%'; ---works in SQL
like '%:give_desc%' ---doesn't work in report builder!!Hi Renil,
You will need to use the wildcard character (%) and the concatenation character (||) to join to your user parameter.
i.e. like '%'||:give_desc||'%'
Regards,
John -
How to pass table type variable into function from SQL*PLUS ?
How to pass a table type variable from sql*plus prompt into a function ?
Thanx in advance.Krishna,
Do you mean like this?SQL> DECLARE
2 TYPE t_tbl IS TABLE OF VARCHAR2(20);
3 l_sample_tbl t_tbl;
4
5 FUNCTION print_contents ( p_tbl IN t_tbl )
6 RETURN VARCHAR2
7 IS
8 l_string VARCHAR2(1000);
9 BEGIN
10 FOR i IN 1..p_tbl.COUNT LOOP
11 IF (i = 1) THEN
12 l_string := p_tbl(i);
13 ELSE
14 l_string := l_string || ', ' || p_tbl(i);
15 END IF;
16 END LOOP;
17 RETURN (l_string);
18 END print_contents;
19
20 BEGIN
21 l_sample_tbl := t_tbl();
22 l_sample_tbl.EXTEND;
23 l_sample_tbl(1) := 'one';
24 l_sample_tbl.EXTEND;
25 l_sample_tbl(2) := 'two';
26 l_sample_tbl.EXTEND;
27 l_sample_tbl(3) := 'three';
28 l_sample_tbl.EXTEND;
29 l_sample_tbl(4) := 'four';
30 l_sample_tbl.EXTEND;
31 l_sample_tbl(5) := 'five';
32 DBMS_OUTPUT.PUT_LINE(print_contents(l_sample_tbl));
33 END;
34 /
one, two, three, four, five
PL/SQL procedure successfully completed.
SQL> HTH,
T.
Maybe you are looking for
-
Full screen on external screen
Hi, I have an iMac and use a TV with the mini-DVI-to-video adapter to view movies from iTunes. All works, but if I set the video to full screen it just shows a small windows inside the black screen.
-
Wrong import warning on JSP page
I've installed NitroX (v/2.0.0 build 371) and started to use it on an existing project. On a JSP page I got a warning: "The import java.io is never used" from the directive: <%@ page buffer="1024kb" autoFlush="true" import="java.util.*, java.io.*"%>
-
Dear Gurus, Am new to extractors and am looking to create the first one. Is it possible to create extractors from structures? As an example, how do I create an extractor using structure MEPO1110 (Fields for Purchase Order Header). BR, Tolu
-
Unable to kill infoview session using LogOnToken
Hi All, I am not able to reuse the EnterpriseSession created in java. I have a java webapp which displays a list of webi reports with hyper-link. when user click on a hyper-link, the web app displays the report in infoview in a iframe element. The pr
-
Metadata and knowledge directory
Does anyone know of a good way to capture extra metadata for documents that are uploaded to the knowledge directory? What we're looking for is a way for users to enter additional properties besides name and description - author, date published, langu