SQL & PL/SQL :: Count Of Date Difference Using Pending State Value In Table Field

Feb 2, 2012

Find the date difference. I need to find that how many days the task is pending, if ACT_NAME field switching from 'SET PENDING%' to 'RESUME PENDING%' by using ACTIONTAKENDATETEXT field in the History table.

Example as needed:
NoPendingDays = 23 (8+15)

I have attached Create table and Insert table values sample as SQL file.

View 10 Replies


ADVERTISEMENT

List Count Of Rows Where DATE Field Is Not Null?

Apr 1, 2010

I need to list a count of rows where a DATE field is not null and group those counts by day.

Here's my sql so far...

SELECT
COUNT(DQ_DISTRBTN_DATE) as DQR_DIST,
DQ_DISTRBTN_DATE as DIST_DATE
from
ETL_PROCESS.BATCH
group by
DQ_DISTRBTN_DATE;

Because DQ_DISTRBTN_DATE contains time, how do I modify to achieve the desired result?

View 2 Replies View Related

SQL & PL/SQL :: Updating A Date Field With Field From Another Table?

Nov 14, 2011

I have a table called Customer_Type with following fields

Customer_type ,Active_date, Inactive_date
regular,11/01/2011
daily,11/04/2011
monthly,11/05/2011/11/11/2011

Tbale 2:Customer

Customer_name,Customer_type,Customer_Inactive_date
John,regular,
James,monthly,
Jake,daily,
Jill,monthly

What i wnat is to update the Customer_inactive_date with the Incative_date field from Customer_type based on their Customer_type... So james and Jill would have their rows updated in this scneario ..How can i achive this in pl/Sql

I have teh code using merge function..I want something in traditional old fashion..

The sql statements are below

CREATE TABLE CUSTOMER_TYPE
(
type_code VARCHAR2(10),

[Code]....

View 5 Replies View Related

Get Count Of Records Grouped By Another Field From Transactions Table

Nov 5, 2009

I have a table that cannot be changed with a field called transaction_reference in the transactions table. This field contains any number of some values in a look-up table called codes.

The table codes contains 'AA', 'BB', 'CC'.

A typical transaction_reference field may look like 'CC BB' or 'AA' or 'AA CC' or 'AA CC BB' - any number, any order.My goal is to get a count of records grouped by another field from the transactions table.

Transactions table example:
transaction_id | transaction_reference | family
---------------------------------------------
1 | AA BB | foo
2 | BB CC | bar
3 | BB | hello
4 | AA CC BB | foo
5 | BB AA | bar

So the results should look like:

family | code | count
foo | AA | 2
foo | BB | 2
foo | CC | 1
bar | AA | 1
bar | BB | 2
bar | CC | 1
hello | AA | 0
hello | BB | 1
hello | CC | 0

If the counts of 0 (like the third to last and last line above) don't show up I'm ok with that.I put together an explode function like this one here but I'm really not sure where to go from here. I can split the transaction_reference, but I'm not sure what to compare it to or how.

I realize that a field in the transactions table for AA, BB, and CC would be ideal, but I can't do that... the powers that be won't let me change the table.

for each exploded segment from transaction_reference
look for it in the codes table
if it exists, add 1 to the count

View 7 Replies View Related

PL/SQL :: Compare Two Rows From Same Table And Show Field And Difference?

Aug 28, 2013

How can I compare two rows from the same table and show the field and the difference?

Example:

select ename, job, mgr, hiredate, sal, deptno
from EMP t
where t.empno = 7782
or t.empno = 7788

ENAME JOB MGR HIREDATE SAL DEPTNO
1 CLARK MANAGER 7839 6/9/1981 2450.00 10
2 SCOTT ANALYST 7566 6/9/1981 3000.00 20

My report comparing fields should be:

FIELD BASE COMPARE DIFFERENCE
ENAME CLARK SCOTT --
JOB MANAGER ANALYST --
MGR 7839 7566 --
SAL 2450 3000 550 --(Show difference only for numbers)
DEPTNO 10 20 --

View 9 Replies View Related

Count Number Of Combinations Of Country / State Invalid For Driving Licenses

May 21, 2012

I'm trying to do a count on the number of combinations of country/state codes that are invalid (in Australia) for driving licenses.

select COUNTRY_CODE, STATE_CODE, count(*) from
(select COUNTRY_CODE, STATE_CODE from CUSTOMER_TABLE
where DRIVING_LICENCE is not null
and not (COUNTRY_CODE in ('AUST') AND STATE_CODE in ('VIC', 'NSW', 'SA', 'QLD', 'NT', 'TAS', 'WA', 'ACT')))
group by COUNTRY_CODE, STATE_CODE

The output is okay...for example I get these results:

INTINT
NZSI
NZINT
AUSTINT
NZNSW
NZ <null>

However, what I am missing is the combination of "AUST" & <null> for country/state respectively. Am I writing the code correctly?

View 1 Replies View Related

PL/SQL :: Calculate Difference By Which Day Count Of Difference Is Going?

Oct 17, 2012

Detail table will look like below:

Product_id issue_date action_date Force_date
1 10/10/2012 10/10/2012 10/10/2012
2 10/10/2012 10/10/2012 10/10/2012
3 10/10/2012 13/10/2012 15/10/2012
[code]....

Need the data like

Issue_date count_action_date count_Force_date (diff(action_date,force_date) 1 2 3 4 5 6(days since over)

10/10/2012 3 4 1 4 2 1 0 0

How to get the data like this? automatically how to get 123.... and how to calculate the difference by which day the count of difference is going?

View 3 Replies View Related

SQL & PL/SQL :: Difference Between Count(*) And Count(1)?

Nov 16, 2009

When we execute select count(*) from table_name it returns the number of rows.

What does count(1) do? What does 1 signifies over here? Is this same as count(*) as it gives the same result on execution?

View 13 Replies View Related

SQL & PL/SQL :: Difference Between Count(1) And Count(*)

Nov 24, 2011

difference between count(1) and count(*). As i know count(*) will give number of rows irrespective of null and count(1) will not count the null.My Oracle version is 10 g.

SQL> select * from t1;

A B C
---------- -------------------- --------------------
1 2 3
2
5

SQL> select rownum,a.* from t1 a;

ROWNUM A B C
---------- ---------- -------------------- --------------------
1 1 2 3
2 2
3 5
4
[code]....

View 3 Replies View Related

Record Count Difference

Mar 19, 2013

I am trying to get a record count of this table and i get 2 different output , select count(*) shows 68560 and after updating the stats the NUM_ROWS shows 68323, why the difference .

SQL> select count(*) from dcepcd;

COUNT(*)
----------
68560

SQL> select num_rows from dba_tables where table_name='DCEPCD';

NUM_ROWS
----------
68323

View 4 Replies View Related

PL/SQL :: Date Difference - Include Both Start And End Date In Range

Aug 8, 2013

select to_date('28-FEB-2013') - TO_DATE('01-FEB-2013')  FROM DUAL 

gives me 27 days, what should I do to get 28 ? meaning include both the start and end dates in the range ?

View 3 Replies View Related

SQL & PL/SQL :: Difference In Num_rows And COUNT Function?

Dec 7, 2012

SELECT COUNT(*) FROM APP.Big_table; Number of record--222653402

This is a big table to get the it's taking 8 minutes time, so that I tried the following SQL to get the count quickly.

SELECT num_rows FROM all_tables WHERE table_NAME='BIG_TABLE'
and owner='APP'; --Number of records 237213998

But I got the different count for the two SQLs. Why there is a difference in the count. Which one is correct.

View 2 Replies View Related

PL/SQL :: Difference In Num_rows And Count Function

Dec 7, 2012

SELECT COUNT(*) FROM APP.Big_table; Number of record--222653402

This is a big table to get the it's taking 8 minutes time, so that I tried the following SQL to get the count quickly.

SELECT num_rows FROM all_tables WHERE table_NAME='BIG_TABLE'

and owner='APP'; --Number of records 237213998But I got the different count for the two SQLs. Why there is a difference in the count. Which one is correct.

View 3 Replies View Related

Application Express :: Unable To Set Default Date Value For Tabular Form DB Date Field?

Dec 3, 2012

Version : 4.1.1, I have a tabular form on a DB table. One of the columns is a date field. When the user hits the "add Row" button on the tabular form, I want the Date field to be defaulted to sysdate. Here is what I have tried so far,

1. Created a "hidden" item P1_SYSDATE and populated the default value with sysdate. After this, under the DB tabular report date field, I used default type - Item/application on this page and entered P1_sYSDATE

2. Instead of populating the default value of the P1_SYSDATE hidden item, I created a before regions process and added

:P1_SYSDATE := sysdate

and added P1_SYSDATE to default type of the tabular date field with default type as "ITem/application on this page.

I get the error

ORA-01790: expression must have same datatype as corresponding expression

I tried to_Char(sysdate,'dd-mon-yyyy') and then converting it back to to_date. still no luck.

View 1 Replies View Related

Converting Date Field To Datestamp (Epoch Date)

Apr 11, 2013

I have a small prolem thats best described like this....

a table called TONY with a field named VISITED (date as YYYYMMDD).

We want to populate the field TIMESTAMP (Last visited timestamp, 18 digits) using midnight or 00:00:00 on VISITED value.

Something like:

UPDATE TONY SET TIMESTAMP = �(whatever the formula is involving VISITED).

but i cannot figure out the best way to derive the TIMESTAMP value...

it's a date to epoch conversion, and i can find many examples of Epoch to date, but thats the wrong way around for me i'm afraid!

Oracle 11gR2 by the way...

View 4 Replies View Related

Forms :: Date Field Gets Disabled When Date Format Is Given?

Oct 3, 2012

A field named xxx_date is a text item which we have to enter manually so as to update a record in that particular date. This is a mandatory field without which we cannot continue the data entry..

I am getting this error while trying to update the record

FRM-40509 :Oracle error :unable to update record

I have kept the enabled = yes
required=no
data type=Date.. in the property pallet

View 2 Replies View Related

How To Use Trigger To Count A Field In A Form

May 16, 2007

I have a form that contains some data and I would like to count them in a new "Item text" ... I don't want to use the Item Text's property where we set the data type to number, database to No, Query all record to Yes and etc... I want to use the SQL statement code to count the records (using trigger)... I named the Item Text as Count_Records .

View 1 Replies View Related

Count Field Not Resetting When Connecting Through VB

Jul 13, 2010

I am working with an asp.net/vb.net application whose users have oracle accounts to connect to the application.The database is set up to allow three failed login attempts. When connecting directly to the database, the sys.user$ lcount field increments on unsuccessful login attempts, and resets to 0 on successful login attepts. This is what I expect should happen.

However, when logging in through the application, using:

objConnection = New OracleConnection(m_strConnectionString)
objConnection.Open()

the lcount field sporatically increments on unsuccessful login attempts (sometimes it does, sometimes it doesn't), and never resets to 0 on successful login attempts. I would have expected it to behave as it does when connecting directly to the database.

Why does the lcount field not reset on a successful login through the application? How can I make it increment on each unsuccessful login attempt and reset on each successful login attempt?

View 1 Replies View Related

SQL & PL/SQL :: Rows With Same Date - Count Date Only Once

Jan 18, 2011

I'm trying to run a script that will sum column values from a table using only a certain period of time in example below only January submissions. However, some of those rows have the same date and I want to have the latest time row of that day in the count.

Oracle 10g

sample 'submit' table

pk loan submit_time
1 105000 1/17/2011 08:05:23 AM
2 204954 1/17/2011 07:59:53 AM
3 159000 1/14/2011 05:25:35 PM
4 215000 1/05/2011 01:06:12 PM
5 340415 12/18/2010 4:34:12 PM

View 2 Replies View Related

SQL & PL/SQL :: Getting Date Gaps From Data Of Date Field

Sep 24, 2011

I have a date field that should be filled everyday with today's date and I need to get the days that were not entered.

i.e. :

CREATE TABLE TRY_F (DAT DATE);

INSERT ALL
INTO TRY_F VALUES (to_date('01/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('02/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('04/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('05/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('06/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('08/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('10/01/2011','DD/MM/YYYY'))
INTO TRY_F VALUES (to_date('14/01/2011','DD/MM/YYYY'))
SELECT * FROM DUAL;

I need a smart way of getting the dates that were missed in DAT.

View 4 Replies View Related

PL/SQL :: Entire Date / Time Value In A Date Field

May 21, 2013

I am having problems with the XMLTable function. I cant get it to see the entire date/time value in a date field. This wont work

select x1.* from XMLTABLE('/DOCUMENT' passing xmltype('<DOCUMENT><STR>abc def ghi</STR><NUM>1234</NUM><DT>2013-02-17T04:24:02</DT></DOCUMENT>') columns STR varchar2(25), NUM number, DT date) x1;

However if I change the DT tag to just the date only "2013-02-17" it works. Why wont Oracle see the entire date/time format even if its ISO 8601 compliant?

Oracle DB: 11.2.0.3.0

View 3 Replies View Related

SQL & PL/SQL :: SELECT With Count Of Rows Depending On Sum Of A Field?

Aug 10, 2011

I want to create a SELECT, that shall give back only a special amount of rows, depending on the sum of one of the selected fields.

At first a code sample of the complete selection:

SELECT DISTINCT mnr, ktxt,
(SELECT Sum(meng_4)FROM reldb d1 WHERE d1.mnr=d.mnr)qty
FROM reldb d
WHERE mnr IN (SELECT mnr FROM relac WHERE Lower(rlnr) NOT LIKE 'platte geprägt%')
AND saext='M'
ORDER BY qty DESC,ktxt;

This selection produces some lines of output (in my case i.e. like 300). What I want to see is only that much lines that the condition 'sum of all items listed below meng_4<=sum of all items meng_4 of the whole selection * 0.9' is fulfilled.

So, if the whole selection produces a total of 10000 as sum for all items meng_4, I want to see only that amount of rows that sums a total of at least 9000 for all items meng_4.
I hope, this specification is exactly enough to understand my intent.

1. Can I do this in a query?

2. If yes, what would this query look like?

View 19 Replies View Related

SQL & PL/SQL :: DBA Pending Transaction In Database

Jun 16, 2011

application was not starting due to some pending transaction in database.Pending transactions were rolled back by DBA team.To avoid such situations what I thought was, having a job that will call a procedure that will monitor table status everyday and will send the mail. Now that job is working fine for no pending transactions in DBA_PENDING_TRANSACTIONS.

But now I am in doubt if someday there are PENDING TRANSACTIONs in the table DBA_PENDING_TRANSACTIONS, will SELECT * FROM DBA_ PENDING_ TRANSACTIONs query will work as normal or this whole process of monitoring table and sending mail will work fine?

View 3 Replies View Related

SQL & PL/SQL :: Pending Purchase Requisitions Without PO

Jun 1, 2010

I am tring to create a query about finding our pending purchuase requestions without PO, we have 4 tables, 2 for PRs & 2 for POs, you can not creat a PO without having a PR,the problem that I tried to find out the pending PRs for all projects and PRs but the query is taking so much time and computer is hanging , is their any way to generate it grouped by project number and PR number and include material in each PR, below is description of all tables related:

PRs table:

MASTER:
--------------------
PRNUMBER
TYPE
MADEBY
PROJECTNUM
[code]....

View 1 Replies View Related

How To Get Date Difference

Jul 20, 2007

How one can get date difference in days between two dates in Oracle reports ?

View 2 Replies View Related

Run A Count On Portion Of Date

Aug 30, 2012

I am trying to run a query that will count the number of each occurrence of a combined month and day. Birthdays are formatted as: 1947-07-26 00:00:00

I need to query everyone in the system who share the same month & day, but not year & time. For example:

1927-07-26 00:00:00
1927-07-26 00:00:00
1987-07-26 00:00:00
1965-07-26 00:00:00
1981-03-14 00:00:00

would give me a Count of 4 for 7/26 and a Count of 1 for 3/14

View 5 Replies View Related

SQL & PL/SQL :: Count Of Records On Each Date?

Jan 26, 2011

PART_REF REGISTERED_BYREGISTERED_DATE
DCA544519 SVK 1/3/2011
DCA544520 SJA 1/3/2011
DCA544539 SJA 1/3/2011
DCA544572 THS 1/3/2011
DCA544608 GKA 1/3/2011
DCA544610 GKA 1/3/2011
DCA544611 THS1 1/3/2011

I just want a to get the total number of records registerd on particular date by particular user...

View 4 Replies View Related

PL/SQL :: Difference Between Real Hijri Date With Oracle Hijri Date

Sep 18, 2012

In my application I show the Date in Hijri using the NLS setting. but the issue that "i face a deference between the real hijri date with oracle hijri date"

Assume that the real hijri date on 18-SEP-2012 was 02/11/1433 in hijri but in oracle was 03/11/1433

when I execute the following query it shows me "1433/11/03", but the actual Hijri date is "1433/11/02"

select to_char(to_date('20120918','YYYYMMDD'),'YYYY/MM/DD', 'NLS_calendar='''||'ARABIC hijrah') FROM DUAL;

View 8 Replies View Related

SQL & PL/SQL :: Count Data Within Date Range?

Nov 15, 2010

I need to know the counts(into buckets) for each event_date for a given event_id.

I have 4 buckets that I'm trying to calculate

1. Past (from Today)
2. Today
3. > Today but within 3 days in the future
4. More than 3 days in the future

WITH event_data AS
(SELECT '1' event_id, SYSDATE - 1 event_date
FROM dual
UNION ALL
SELECT '1' event_id, SYSDATE
FROM dual

[code]....

Sample Output:

EVENT_IDPASTTODAYWITHIN_3_DAY_WINDOWOUTSIDE_3_DAY_WINDOW
1 111 1
2 102 0

View 3 Replies View Related

SQL & PL/SQL :: Difference Between Two Date Type Fields

Aug 15, 2011

I'm having trouble comparing and subtract two date type fields, can not get a significant result.

e.g.

select id, date.started, date.closed, datediff (day, date.started, date.closed) differences diference from Table1 order by desc;

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved