Fault cases identification using Sql query
Hi ,
i have data in below format.using below data to extract the fault cases.
operator machine fromdate todate
1491 QC03 2014-09-02 02:51:00.000 2014-09-02 06:10:00.000
1427 QC03 2014-09-02 06:11:00.000 2014-09-02 07:17:00.000
1491 QC03 2014-09-02 11:21:00.000 2014-09-02 14:50:00.000
1595 QC03 2014-09-02 03:10:00.000 2014-09-02 08:25:00.000
we need to fetch the falut cases from the above mentioned data.
emp is working on different time on specified machines. In some cases multilple employuees working
on
specifed Machines on Same time.
In above Example case 1491,1595 operators working time is Overlapping.
we need to check emp working same time on Same machine(Fault cases)
Anybody know the way pls guide on the same...
Hi KONDAPATURU,
There are 2 ways that you can go about in getting the solution. They are listed below.
Approach
1
USING CROSS APPLY
Declare @FaultCases table
operator int,
machine varchar(10),
fromdate datetime,
todate datetime
-- Sample values
insert into @FaultCases (operator,machine,fromdate,todate) values
(1491,'QC03','2014-09-02 02:51:00.000','2014-09-02 06:10:00.000'),
(1427,'QC03','2014-09-02 06:11:00.000','2014-09-02 07:17:00.000'),
(1491,'QC03','2014-09-02 11:21:00.000','2014-09-02 14:50:00.000'),
(1595,'QC03','2014-09-02 03:10:00.000','2014-09-02 08:25:00.000'),
(1596,'QC03','2014-09-02 03:11:00.000','2014-09-02 08:35:00.000')
-- Cross Apply Query
SELECT F.*
FROM @FaultCases F
CROSS APPLY
SELECT COUNT(*) AS NumberOfOccurances
FROM @FaultCases
WHERE machine = F.machine
AND operator <> F.operator
AND
(fromdate BETWEEN F.fromdate AND F.todate)
OR
(todate BETWEEN F.fromdate AND F.todate)
)OP
WHERE NumberOfOccurances > 0
Approach 2
USING CTE
Declare @FaultCases table
operator int,
machine varchar(10),
fromdate datetime,
todate datetime
DECLARE @OUTPUTFaultCases table
operator int,
machine varchar(10),
fromdate datetime,
todate datetime
insert into @FaultCases (operator,machine,fromdate,todate) values
(1491,'QC03','2014-09-02 02:51:00.000','2014-09-02 06:10:00.000'),
(1427,'QC03','2014-09-02 06:11:00.000','2014-09-02 07:17:00.000'),
(1491,'QC03','2014-09-02 11:21:00.000','2014-09-02 14:50:00.000'),
(1595,'QC03','2014-09-02 03:10:00.000','2014-09-02 08:25:00.000'),
(1596,'QC03','2014-09-02 03:11:00.000','2014-09-02 08:35:00.000')
-- USING CTE to get all rows where fromDate or ToDate lies between fromDate and todate of table's rows. This process is done row by row.
;WITH CTE
AS
SELECT ROW_NUMBER() OVER (order by operator) RowId, * from @FaultCases
SELECT * INTO #Output from CTE
DECLARE @TotalCount int , @RowId int = 1
SELECT @TotalCount = COUNT(*) from #Output
WHILE @RowId <= @TotalCount
BEGIN
DECLARE @fromdate datetime, @todate datetime
SELECT @fromdate = fromdate, @todate = todate FROM #Output WHERE RowId = @RowId
INSERT INTO @OUTPUTFaultCases
SELECT operator, machine, fromdate, todate
FROM #Output
WHERE
(@fromdate BETWEEN fromdate AND todate)
OR
(@todate BETWEEN fromdate AND todate)
AND RowId <> @RowId
SELECT @RowId+=1
END
DROP TABLE #Output
SELECT DISTINCT * FROM @OUTPUTFaultCases
In both cases the output is as per below screenshot.
Please "Mark as Answer" if it answers your question.
Vijeth Sankethi
Similar Messages
-
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 -
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 -
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? -
List of Project Permission in PS 2010 Using SQL query
Hi
Is there any way to get a list of Project permissions associated with user using sql query. If i go manually Project center --> select project plan --> project permission it would take lot of time to find out for each user
Regards
SantoshBefore you continue (which you probably will overlook) - please understand that you should only be querying the REPORTING database and not the published database. A recommendation is to use a select statement statement to insert the tables into a table
int the reporting database, then query that table for your results/report.
The following page I believe has what you're looking for (Users with direct permissions- query below)
and more
http://pmpspecialists.com/Blog/2013/10/
SELECT MSP_RESOURCES.RES_NAME AS Resourcename, CONV.CONV_STRING AS Permission, MSP_WEB_SECURITY_SP_CAT_PERMISSIONS.WSEC_DENY AS Denied,
MSP_WEB_SECURITY_SP_CAT_PERMISSIONS.WSEC_ALLOW AS Allowed
FROM MSP_WEB_SECURITY_SP_CAT_PERMISSIONS INNER JOIN
MSP_WEB_SECURITY_SP_CAT_RELATIONS ON
MSP_WEB_SECURITY_SP_CAT_PERMISSIONS.WSEC_REL_UID = MSP_WEB_SECURITY_SP_CAT_RELATIONS.WSEC_REL_UID INNER JOIN
MSP_WEB_SECURITY_FEATURES_ACTIONS ON
MSP_WEB_SECURITY_FEATURES_ACTIONS.WSEC_FEA_ACT_UID = MSP_WEB_SECURITY_SP_CAT_PERMISSIONS.WSEC_FEA_ACT_UID INNER JOIN
MSP_WEB_CONVERSIONS AS CONV ON CONV.CONV_VALUE = MSP_WEB_SECURITY_FEATURES_ACTIONS.WSEC_FEA_ACT_NAME_ID INNER JOIN
MSP_RESOURCES ON MSP_WEB_SECURITY_SP_CAT_RELATIONS.WSEC_SP_GUID = MSP_RESOURCES.RES_SECURITY_GUID
WHERE (CONV.LANG_ID = 1033)
ORDER BY Resourcename, Permission -
How to show the VALUE as the Column Header using SQL query?
Hi
I have a requirement to show the picked value as the column header using SQL query.
Example:
======
SELECT EMPNO FROM EMP
WHERE EMPNO=7934;
Result Should be:
7934
7934I have a requirement to show the picked value as the column header using SQL query.In sql*plus you can do
SQL> set verify on
SQL> def e = 7934
old: SELECT empno "&&e" FROM emp WHERE empno = &&e
new: SELECT empno "7934" FROM emp WHERE empno = 7934
SQL> SELECT empno "7934" FROM emp WHERE empno = 7934
7934
7934
1 row selected. -
How to backup database using sql query?
Hello,i'm student, i'm researching oracle database,i want to backup database that using sql query (like backup query in SQL SERVER) ,how to do that ??
Thank!No, database backups cannot be done from within the database.
Commands for backups are outside of the database.
See the "2 Day DBA Guide" http://download.oracle.com/docs/cd/E11882_01/server.112/e10897/toc.htm
and the "Backup and Recovery Users's (actually Adminsitrator's) Guide : http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/toc.htm
Hemant K Chitale -
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. -
How to get this output using sql query?
Hi,
How to get this output using sql query?
Sno Name Age ADD Result
1 Anil 23 delhi Pass
2 Shruti 25 bangalor Pass
3 Arun 21 delhi fail
4 Sonu 23 pune Pass
5 Roji 26 hydrabad fail
6 Anil 28 delhi pass
Output
Sno Name Age ADD Result
1 Anil 23 delhi pass
28 delhi passHi Vamshi,
Your query is not pretty clear.
write the select query using Name = 'ANIL' in where condition and display the ouput using Control-break statements.
Regards,
Kannan
Maybe you are looking for
-
NtfsServer problem on Windows 2000 Advanced Server
I've installed Oracle 8.1.6 and iFS 1.0 on Windows 2000 Advanced Server. Everything else seems to work fine with iFS, but the NtfsServer always fails to start up. Is this a compatibility problem between Oracle and Windows 2000? I have no drive letter
-
Why do I get a windows error every time I stop or close an executable?
Whenever I run an executable in any windows computer it runs fine but as soon as I stop or shut down the executable, I get and a windows error. The program that I have reads from compact Fieldpoints and processes those data. Once you close or stop th
-
Canada - Bank transit number - routing code
hello! I am working in a Belgian company using ECC 6.0 and I have to pay a vendor which is in Canada. My bank told me i have to add the Canadian routing number (in French : code de transit) before the bank account. But in SAP, i dont know where shoul
-
HOUSE BANK - Account ID, Bank Key, Swift Code
Hi All, I hv doubt in customisation of a house bank. While configuring a house bank, we need:- 1) Account ID 2) Bank Key 3) Swift Code could anybody please explain what is the role of these 3 items when we run Automatic Payment Programme & manual
-
I need to back up my iMovie DVDs. I recently had my Seagate External Hard Drive go bad. Seagate replaced the drive but not all the iMovie projects i had backed up there. Is there a way to do this from theDVDs i burned the iMovie projects to? The