[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

neee to modify a query in sql 2000 query analyser to return names instead of ids

Posted on 2008-10-09
7
Medium Priority
?
211 Views
Last Modified: 2012-05-05
Hi,
I need to adjust the sql query (see  attachment)  in query analyser to return the first and last names of the log agents.
The log agents column  references the ctct table.
The ctct table holds names for both Customers and Log agents.
Thanks.

customers-and-log-agents.doc
0
Comment
Question by:blossompark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 22678457
I couldn't read the doc, can you just post the query?
0
 
LVL 31

Expert Comment

by:James Murrell
ID: 22678472
code you just paste code...
0
 

Author Comment

by:blossompark
ID: 22678661
Hi,
this is the code;
declare @date2 int
select @date2=datediff(second,convert(datetime,'1/1/70',3),(select getdate()))
select ref_num as Incident#,summary as Summary, description as Description,status as Status,
ahd.ctct.c_first_name as Customer,ahd.ctct.c_last_name as _,ahd.call_req.log_agent,
CAST(DATEADD(second,AHD.call_req.open_date + 3200 , '1970-01-01 00:00:00') AS smalldatetime) AS Open_date,
 CAST(DATEADD(second,AHD.call_req.last_mod_dt + 3200 , '1970-01-01 00:00:00') AS smalldatetime)  as Last_updated
 from ahd.Call_req, ahd.ctct
where
 ahd.call_req.customer = ahd.ctct.id

and active_flag=1
0
 
LVL 23

Accepted Solution

by:
Snarf0001 earned 2000 total points
ID: 22678668
I'm assuming ctct is a table just holding ids and names?  Taking a few guesses here, as I have no idea what the table structure is, but try something like below:

You're going to have to use joins instead of just table lists
I also modified the first date2 select a bit.

declare @date2 int
 
--select @date2 = datediff(second, convert(datetime, '1/1/70', 3), (select getdate()))
set @date2 = datediff(second, convert(datetime, '1/1/70', 3), getdate())
 
select ref_num as Incident#, Summary, Description, Status,
cust.c_first_name as Customer, cust.c_last_name as _, 
agent.c_first_name as LogAgentFirstName, agent.c_last_name as LogAgentLastName,
ahd.call_req.log_agent,
cast (dateadd(second, AHD.call_req.open_date + 3200, '1970-01-01 00:00:00') as smalldatetime) as Open_date,
cast (dateadd(second, AHD.call_req.last_mode_dt + 3200, '1970-01-01 00:00:00') as smalldatetime) as Last_updated
from ahd.Call_req cr
join ahd.ctct cust on cr.customer = ctct.id
join ahd.ctct agent on cr.log_agent = ctct.id
where active_flag = 1

Open in new window

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question