473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how can i update my table with the elapasedsecond as a new coloumn

i have generated the difference between two rows of my data using this code.....
now i have the ElapsedSecond as one new row how can i save it into my table??


SELECT *,
DATEDIFF(second, A.End_Time,
(SELECT MIN(Start_Time)
FROM Callbycall as B
WHERE A.Agent = B.Agent
AND A.Start_Time < B.End_Time)) as ElapsedSecond
FROM Callbycall as A
Dec 9 '09 #1
3 1061
nbiswas
149 100+
Try something like

Expand|Select|Wrap|Line Numbers
  1. insert into tablename
  2. select * from tablename
syntax

e.g.

Expand|Select|Wrap|Line Numbers
  1. insert into Callbycall
  2.  
  3. SELECT *,
  4. DATEDIFF(second, A.End_Time,
  5. (SELECT MIN(Start_Time)
  6. FROM Callbycall as B
  7. WHERE A.Agent = B.Agent
  8. AND A.Start_Time < B.End_Time)) as ElapsedSecond
  9. FROM Callbycall as A

Hope this helps
Dec 9 '09 #2
will this code help me to update the table which i am having..
this is insert i would like to hava a update statement which would help me to insert the values.
Dec 10 '09 #3
nbiswas
149 100+
The general syntax for this case is

Expand|Select|Wrap|Line Numbers
  1. UPDATE <destinationtablename>
  2. SET <destinationtablename.columnname> = <sourcetablename.columnname>
  3. FROM < sourcetablename >
  4.     INNER JOIN < destinationtablename >
  5.     ON (<destinationtablename.columnname> = <sourcetablename.columnname>);
Coming to your program, try this(you may need to modify a bit as I don't have the exact schema)

Expand|Select|Wrap|Line Numbers
  1. UPDATE DESTINATION_TABLE
  2. SET DESTINATION_TABLE.ElapsedSecond= S.ElapsedSecond
  3. FROM 
  4. (SELECT *,
  5. DATEDIFF(second, A.End_Time,
  6. (SELECT MIN(Start_Time)
  7. FROM Callbycall as B
  8. WHERE A.Agent = B.Agent
  9. AND A.Start_Time < B.End_Time)) as ElapsedSecond
  10. FROM Callbycall as A) S
  11.  
  12. INNER JOIN DESTINATION_TABLE D
  13. ON D.JOIN_FIELD_NAME = S.JOIN_FIELD_NAME
I have given a similar response to you question here how to insert the value of a function in the coloum

Hope this helps
Dec 11 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
2
by: amy | last post by:
Hi, all: i am a new end user of access, now I have many excel files need to import to One table in access (combine all excel files into one table in excel). In excel files, some columns will have...
0
by: amy | last post by:
Hi, all: > i am a new end user of access, now I have many excel files need to > import to One table in access (combine all excel files into one table > in excel). In excel files, some columns will...
1
by: Rohit111111 | last post by:
Hello How can i use the table control ,meanse i have to make rows and coloumn dynamically with proper pagination
1
by: jignasha1234567 | last post by:
hi, how can i delete data from one table which is similar to another data in another table having same coloumn name. suppose i have one table name test1 and another table named test2 . ...
3
by: supermen | last post by:
to all, how to split a column into 5 coloumn. e.g column= 1 2 1 3 4 into colomn1 = 1 colomn2 = 2 colomn3 = 1 colomn4 = 3 colomn5 = 4
1
by: vineeth006 | last post by:
respected sir, iam new to vb.net.i just want to know how we can edit a table from datagridview.and also i have a small problem in retrieving table from sql to a gridview when i...
3
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID...
1
by: jay123 | last post by:
hi all, i m struck with very pericular problem. my problem is i have store proc as ALTER PROCEDURE . (@RowID UniqueIdentifier, @ID int, @Type Varchar(100), ) AS
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.