Jump to content

strangely familiar

Members
  • Posts

    4
  • Joined

  • Last visited

About strangely familiar

  • Birthday 04/29/1974

Contact Methods

  • Website URL
    http://www.myspace.com/squirrelgirlsrule
  • Yahoo
    strangelyfamiliar01@yahoo.com

Profile Information

  • Gender
    Male
  • Location
    Dearborn, MI
  • Interests
    i like stuff :)

strangely familiar's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Congratulations with your birthday :)

  2. maybe i'm not asking the question correctly? can anyone help me?thanks
  3. I'm having a problem with getting the data I need from the query below. Basically, I'm looking at changes that were made to a set of records, and trying to use the change log to revert back to the original value for my report. The problem is, the query is not pulling the "right" row from the audit log.Here's the query:SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED Select TSK.TaskID AS 'task_id', AUD.TaskAuditID AS 'task_audit_id', RTE.Description AS 'route_to', RT2.Description AS 'route_to_orig', TYP.Description AS 'TaskType', SUB.Description AS 'SubTaskType', STA.Description AS 'StatusID', CUS.CustID AS 'CustID', CONVERT(char(10), TSK.CreatedDate, 126) AS 'CreatedDate', CONVERT(char(10), TSK.ClosedDate, 126) as 'ClosedDate', Case When Cus.CustomerCountry in ('USA', 'US') THEN 'US' When Cus.CustomerCountry = 'CA' Then 'Canada' Else 'Other' End as 'Country', CUS.ACNSystemOwner As 'System', CUS.Serviceclass AS 'SvcClass'FROM ACN_Extensions.dbo.ACN_CCPCaseManagementTask TSK left outer join ACN_Extensions.dbo.ACN_CCPCaseManagementRoute RTE on TSK.RouteID = RTE.RouteID left outer join ACN_Extensions.dbo.ACN_CCPCaseManagementTaskAudit AUD on AUD.TaskID = TSK.TaskID and AUD.ColumnName = 'RouteID' left outer join ACN_Extensions.dbo.ACN_CCPCaseManagementRoute RT2 on AUD.OriginalValue = RT2.RouteID, ACN_Extensions.dbo.ACN_CCPCaseManagementTaskType TYP, ACN_Extensions.dbo.ACN_CCPCaseManagementSubTaskType SUB, ACN_Extensions.dbo.ACNCustomer CUS, ACN_Extensions.dbo.ACN_CCPCaseManagementStatus STA WHERE TSK.CreatedDate >= DateAdd(dd,DateDiff(dd,0,getdate()-7),0) and TSK.CreatedDate < DateAdd(dd,DateDiff(dd,0,getdate()),0) and (TSK.CreatedBy <> TSK.ClosedBy OR TSK.ClosedBy IS NULL) and TSK.TaskTypeID = TYP.TaskTypeID and TSK.SubTaskTypeID =SUB.SubTaskTypeID and TSK.CustID=Cus.CustID and TSK.StatusID = STA.StatusIDORDER BY TSK.TaskIDExcerpt of results includes:task_id, task_audit_id, route_to, route_to_orig5973661, 4712577, Customer Care - CSA, Customer Care - Tier 2 Support5973661, 4729011, Customer Care - CSA, Customer Care - Research5973661, 4731482, Customer Care - CSA, Customer Care - SupervisorI want to get this to only one row of the task_id and the task_audit_id that is the smallest number. I've tried adding DISTINCT to the query, but it just grabs any old task_audit_id, not the one I want. I'm at a total loss on this one...task_id, task_audit_id, route_to, route_to_orig5973661, 4712577, Customer Care - CSA, Customer Care - Tier 2 SupportPlease help.
  4. Sorry, I'm probably not asking the question properly. I changed what you said, but there are still multiple records with the same CustID. I need only one record for each CustID, along with the TaskID that is the largest number, and the ServiceNumber. Changing the sort does not remove the extra records from the result...
  5. Hi :)I'm new to SQL and the forum, and hoping someone can help. I'm trying to pull data for a report...not sure if I'm on the right track or not...For all records found with the selected criteria, I need the top TaskID...here's what I have so far...QUERY:SELECT WRP.CustID, CMT.TaskID, CMT.ServiceNumber FROM dbo.ACN_CCPWrapCode WRP, dbo.ACN_CCPCaseManagementTask CMT WHERE WRP.CustID=CMT.CustID AND WRP.CallTypeID = '6' AND WRP.CallCategoryID = '223'AND WRP.CallCategoryReasonID = '427' AND WRP.DateCreated between '2006-09-12 00:00:00.000' and '2006-09-12 23:59:26.599'ORDER BY WRP.CustID, CMT.TaskID DESCRESULTS:CustID TaskID ServiceNumber47267 5388607 650728532447267 5326788 650728532447267 5136222 650728532447267 4946900 650728532460947 5388944 716823147660947 5345550 716823147660947 5319921 716823147660947 5319901 716823147660947 5294399 716823147660947 5249701 716823147660947 188072 716823147664983 5361067 716691600489501 5393686 708449562489501 5390907 708449562489501 5388819 708449562489501 5359178 7084495624I want the results to contain the first row for each CustID, with the newest TaskID (greatest number), so I would like the result to look like this:47267 5388607 650728532460947 5388944 716823147664983 5361067 716691600489501 5393686 7084495624Does anyone know how to do this?thanks
×
×
  • Create New...