Query to find Last updated..
Hi all,
If I have a table with accounts, users and last_on_date, how can I find the user who accessed an account most recently.
Say, the table is as follows:
a/c user c_date
a1 u1 03/04/2007
a1 u2 03/05/2007
a2 u3 03/05/2007
a2 u1 03/07/2007
a2 u2 03/06/2007
a3 u3 04/05/2007
What query would fetch the following:
a/c user c_date
a1 u2 03/05/2007
a2 u1 03/07/2007
a3 u3 04/05/2007
Any help is appreciated.
That's only part of the OP's Q.
The OP asked for the most recent user of a particular account not the most recent access of each user to each account.
so this would do the trick:
SELECT AC,
USER,
C_DATE
FROM (SELECT AC,
USER,
C_DATE,
ROW_NUMBER() OVER (PARTITION BY AC ORDER BY C_DATE DESC) RN
FROM YOUR_TABLE)
WHERE RN = 1;
Similar Messages
-
To find last updated date in sql developer for a procedure or a function
hi
how to to find last updated date in sql developer for a procedure or a function.
i m using sql developer version in 1.2I think you are in the wrong forum...
Anyway you can try
select * from
all_objects o
where o.object_type in ('FUNCTION','PROCEDURE');
you have there the created date, last DDL and timestamp -
SCCM query to find last logon server info
dear
all
could u please share an sccm query to find all client logon server ie mean we get once set L command is put
ankithhi
I Have the same query added logon server
SELECT
v_GS_SYSTEM.Name0
AS ComputerName,
v_GS_NETWORK_LOGIN_PROFILE.TimeStamp
AS [Last Login Time],
v_GS_NETWORK_LOGIN_PROFILE
.Name0
AS [Logon User],
v_GS_SYSTEM.Domain0
AS [Logon Domain],
v_GS_SYSTEM.SystemRole0
AS [System Role],
v_GS_SYSTEM
.SystemType0
AS [System Type],
v_GS_NETWORK_LOGIN_PROFILE.LogonServer0
FROM
v_GS_NETWORK_LOGIN_PROFILE
LEFT
OUTER
JOIN
v_GS_SYSTEM
ON v_GS_NETWORK_LOGIN_PROFILE.ResourceID
= v_GS_SYSTEM.ResourceID
WHERE
(v_GS_NETWORK_LOGIN_PROFILE.LastLogon0
IS
NOT
NULL)
once query executed iam getting in output
ankith -
hi,
Can anyone please provide me a query to find out names having " , " commas like servi,ce actually I have a service name column in a table where i need to find names with commas "," and remove by update.
I appreciate, if anyone provide me query to find those services having commas in between and a separate update statement to remove them
Thanks in advance for your cooperation
Regards,
ahonhello
used the sql command REPLACE & INSTR function
example :
Query :
select service_name
from YOURTABLE
where instr(service_name,',') > 0 -- This return those with ',' char
to update :
update YOURTABLE
set service_name = replace(service_name,',','') -- to replace the ',' char to null values
where instr(service_name,',') > 0
But before doing that back up your table or do it in a copy of that..
Syntax
REPLACE ( string_expression , string_pattern , string_replacement )
Arguments
string_expression
Is the string expression to be searched. string_expression can be of a character or binary data type.
string_pattern
Is the substring to be found. string_pattern can be of a character or binary data type. string_pattern cannot be an empty string (''), and must not exceed the maximum number of bytes that fits on a page.
string_replacement
Is the replacement string. string_replacement can be of a character or binary data type.
charles.
if this find helpful or correct then mark it accordingly -
Query to get last updated time of tables
Hi,
How to get the last updated date time of the Max DB table
Regards,
SatishHi,
Unfortunately, do not this this would be possible. Check this thread:
MAXDB Audit logs
Regards,
Srikishan -
Query to find duplicates, update appropriately, delete one of those duplicate
I have duplicate rows in below given table and need to cleanse it by observing another duplicate record.
I'd like to know various ways to achieve it. (I'm confused I should use UPDATE.. (CASE WHEN.. THEN).. or MERGE or something else)
Please find below DDL/DML.
create table MyTable
PKey int identity(1,1),
CustID int,
FirstName varchar(10),
LastName varchar(10),
Main varchar(10),
Department varchar(10)
Insert into MyTable
select 101, 'aaa','bbb','VM','Marketing' union
select 101, '', '','','' union
select 102, '', 'yyy', 'Main', 'Marketing' union
select 102, 'xxx','','','' union
select 103, 'ppp', 'qqq', '', 'HR' union
select 103, '', '', 'MF', '' union
select 104, 'mmm', 'nnn', 'f', 'dept'
select * from mytable
--PKey CustID FirstName LastName Main Department
--2 101 aaa bbb VM Marketing
--3 102 xxx yyy Main Marketing
--6 103 ppp qqq MF HR
--7 104 mmm nnn f dept
Cheers,
Vaibhav ChaudhariHi Vaibhav,
Manu's has copied as a part of the below code.
create table MyTable
PKey int identity(1,1),
CustID int,
FirstName varchar(10),
LastName varchar(10),
Main varchar(10),
Department varchar(10)
Insert into MyTable--(CustID,FirstName,LastName,Main,Department)
select 101, 'aaa','bbb','VM','Marketing' union
select 101, '', '','','' union
select 102, '', 'yyy', 'Main', 'Marketing' union
select 102, 'xxx','','','' union
select 103, 'ppp', 'qqq', '', 'HR' union
select 103, '', '', 'MF', '' union
select 104, 'mmm', 'nnn', 'f', 'dept'
SELECT * FROM MyTable;
;WITH cte AS
SELECT DISTINCT
MAX(PKey) PKey,
CustID,
MAX(FirstName) AS FirstName,
MAX(LastName)AS LastName,
MAX(Main) AS Main,
MAX(Department) AS Department
FROM mytable
GROUP BY CustID
MERGE mytable AS Tar
USING cte AS Src
ON Tar.PKey = Src.PKey
WHEN MATCHED THEN
UPDATE SET Tar.CustID = Src.CustID, Tar.FirstName = Src.FirstName,Tar.LastName = Src.LastName, Tar.Main = Src.Main,Tar.Department = Src.Department
WHEN NOT MATCHED BY SOURCE THEN
DELETE
SELECT * FROM MyTable
DROP TABLE MyTable;
If you do care about the Identity Pkey, as per the expected output, my understanding on your logic is like below.
;WITH cte AS
SELECT PKey, CustID,V1,V2,V3,V4,ROW_NUMBER() OVER(PARTITION BY CustID ORDER BY v1+v2+v3+v4 DESC) AS RN
FROM MyTable
CROSS APPLY(SELECT CASE WHEN FirstName ='' THEN 0 ELSE 1 END AS v1) AS cat1
CROSS APPLY(SELECT CASE WHEN LastName ='' THEN 0 ELSE 1 END AS v2) AS cat2
CROSS APPLY(SELECT CASE WHEN Main ='' THEN 0 ELSE 1 END AS v3) AS cat3
CROSS APPLY(SELECT CASE WHEN Department ='' THEN 0 ELSE 1 END AS v4) AS cat4
,cte2 AS
SELECT DISTINCT
CustID,
MAX(FirstName) AS FirstName,
MAX(LastName)AS LastName,
MAX(Main) AS Main,
MAX(Department) AS Department
FROM mytable
GROUP BY CustID
,cte3 AS
SELECT c2.CustID,c2.FirstName,c2.LastName,c2.Main,c2.Department,c.PKey FROM cte2 c2 JOIN cte c ON c.CustID = c2.CustID WHERE NOT EXISTS(SELECT 1 FROM cte WHERE RN<c.RN)
MERGE mytable AS Tar
USING cte3 AS Src
ON Tar.PKey = Src.PKey
WHEN MATCHED THEN
UPDATE SET Tar.CustID = Src.CustID, Tar.FirstName = Src.FirstName,Tar.LastName = Src.LastName, Tar.Main = Src.Main,Tar.Department = Src.Department
WHEN NOT MATCHED BY SOURCE THEN
DELETE
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Hello,
Our DBA wants to know which records have been updated since the last backup so that he can back up only those records that have been added/changed on the next backup. He is putting a column called Timestamp in each table he wants to do this for. The field will be filled with sysdate on insert/change by a trigger in order that he can know which to select for back up. My question is, does oracle (8.1.6) have any built in method for tracking the time that records have been updated? Perhaps in the system tables or views?
Thanks
ThessaHi,
as far as I know, Oracle 8 has a feature to do incremental backups. But I think they perform it on the change og DB Blocks not on DB Rows.
HTH
Detlev
null -
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 -
Vendor ID, Last Update Date, Invoice Details - Query
For each Supplier, we would like to know the vendor ID, vendor number, vendor name, vendor site code, Created Date, Last Update Date, last invoice date, last payment date, total number of invoices and total $ amount of invoices for each supplier.
1) How do i find the last payment date and supplier catagory?
2) As i have to use sum(invoice_amount), count(invoice_amount), max(payment_date) which point to 3 different tables, i am not sure how to use "group by" based on the Vendor_id alone while i select lot of fields from different table. Could you please help me with this?
3) Please help me to get this query fixed.1) You can get last_payment_date by joining vendor_id to ap_invoices_all and the joining invoice_id with ap_invoice_payments_all to get the max accounting_date (i.e. last payment date)
2) You are partially right. Invoice_amount and invoice_count are from the same table so you have to join 2 tables. Best way is to do a select in the select.
e.g SELECT pv.vendor_name, COUNT (1), SUM (invoice_amount), pv.vendor_id,
(SELECT MAX (aipa.accounting_date)
FROM ap_invoice_payments_all aipa, ap_invoices_all aia2
WHERE aia2.vendor_id = pv.vendor_id
AND aia2.invoice_id = aipa.invoice_id) latest_payment
FROM ap_invoices_all aia, po_vendors pv
WHERE aia.vendor_id = pv.vendor_id
GROUP BY pv.vendor_name, pv.vendor_idSandeep Gandhi -
How to find the last update date time and user of record field peoplecode
how to find the last update date time record field peoplecode?
Thank you.One can check the last update date time using the following query
SELECT LASTUPDDTTM FROM PSPCMPROG WHERE OBJECTVALUE1 LIKE 'RECNAME' AND OBJECTVALUE2 LIKE 'FIELDNAME' -
To find last inserted or updated date from an schema
Hi,
i need a query to find the list of tables which was last updated or inserted (upto 2003) from a schema..
Rgds.Such information is nowhere stored , the only 'date' column in DBA_TABLES is 'LAST_ANALYZED'.
Werner -
How can I find the user that created a user account and the user who last updated the account
How can I find out who created a user account and who last updated the account. I think that this is the same information that is displayed in the description field on the General tab.
I am using ADO commands and vbscript
ug3jI should point out that there are two attributes of all AD objects that can help you track down the correct information in the system logs. These are the whenCreated and whenChanged attributes. This will tell when the object was created and when it was last
modified, which should help when you search the logs. Also, while whenCreated is replicated to all DC's, so they will all have the exact same creation time, the whenChanged attribute is technically not replicated. The date/time on each DC reflects when
the last modification was replicated to that DC. The values will differ slightly on each DC, reflecting how long it took for the change to replicate.
Richard Mueller - MVP Directory Services -
Looking for a query to find first/last dates in overlapping dates...
Hi,
I'm looking for a query to find the first dates and last dates in a table conaining overlapping dates.
I have a subscription table which has for each Customer start and end date for different subscriptions.
I want to know the different ranges of date where there is subscriptions active.
so if the table has this:
CustID, Start date, end date
1, 2008-01-01, 2012-06-06
1 ,2009-01-01, 2011-01-01
1, 2011-01-01, 2013-02-02
1, 2013-01-01, 2013-08-08
1, 2014-01-01, 2014-04-04
I want to produce this result:
custid, range start, range end
1, 2008-01-01, 2013-08-08
1, 2014-01-01, 2014-04-04
the first row is the range identified from the 4 rows in my subscription table.
thanks :)I think I found it...
http://stackoverflow.com/questions/5213484/eliminate-and-reduce-overlapping-date-ranges
let me try this method
Hi,
m writing to follow up with you on this post. Thanks for you posting a reply to share your workground. Was the problem resolved after performing the above link? If you are satisfied with the above solution, I’d like to mark this issue as "Answered".
Please also feel free to unmark the issue, with any new findings or concerns you may have.
Thanks,
Sofiya Li
If you have any feedback on our support, please click here.
Sofiya Li
TechNet Community Support -
after the last update(7.1.2) i couldn't find personal hotspot in my iPad 2 Wifi+Cellular. I did everything like reset network setting, restore to factory setting and set up as a new iPad but no change. My iPhone 5's carrier is 16.2 and after update to 7.1.2 it automatically ask me for carrier update but my iPad 2 ask nothing and the carrier is 16.1. Please, help me to solve this problem.
The Personal Hotspot feature is not available on the iPad 2. I have no idea how you could have been using it before as you claim. BTW, your screenshots do not show up.
System requirements
The table below lists the iPhone and iPad (Wi-Fi + Cellular models) capable of Personal Hotspot and which connections they can use to share cellular data with another device:
USB
Bluetooth
Wi-Fi
iPhone 4 or later
✓
✓
✓
iPhone 3GS and iPhone 3G*
✓
✓
iPad (3rd generation or later) Wi-Fi + Cellular
✓
✓
✓
iPad mini Wi-Fi + Cellular
✓
✓
✓
* On iPhone 3G, Personal Hotspot is referred to as Internet tethering.
To connect to a Personal Hotspot, your device requires:
Wi-Fi: Support for 802.11g/n using WPA2 encryption.
USB: Mac or PC with iTunes 9.2 or later installed.
Bluetooth: Mac OS X v10.4.11 or Windows. -
Since I installed the last update, ITunes no longer finds my iPhone when it is pluged in my laptop. I can longer sync my calander and Outlook!
Why is that and can this be fix?DEVICE NOT RECOGNISED IN ITUNES
If you have connected your device to your computer and it does not appear in the side bar in iTunes then for Windows computers read http://support.apple.com/kb/TS1538 or if you have a MAC then read http://support.apple.com/kb/ts1591 for troubleshooting steps.
Maybe you are looking for
-
PCI-E Audio Sounds Terrible?
For years I have been using an X-Fi Platinum PCI card and have been very happy with it. This past August it died and I decided to replace it, and do away with my SLI rig. I purchased an EVGA GTX 760 4G FTW video card and a Recon 3D Fatality Champion
-
I am using Portal Server 7.1u1 on windows 2003. I wanted to use survey portlet with a customized enterprise sample, but after I added it I always get content not found error. Can anyone help me with some links for configuring it. Also I wanted to use
-
10g Database Exams and Certifications being retired 01-Mar-2015
Please note that 10g Database Exams and Certifications are being retired 01-Mar-2015 https://blogs.oracle.com/certification/entry/1060_01 Hemant K Chitale
-
I have an IPhone 4S. How do I see if there are any apps open in the background and if so, should they be deleted to save energy? Thanks
-
Dear All, I am mid way through delivery of an MPLS network for a customer. We have the option of adding a DMVPN internet backup. The WAN routing protocol is BGP for both DMVPN and MPLS (MPLS is straight routing - no overlay or getvpn) The customer ha