troubleshooting Question

Help in MS SQL

Avatar of AmitavaCh
AmitavaChFlag for India asked on
Microsoft SQL Server 2005
3 Comments1 Solution238 ViewsLast Modified:
Hi,

The following query gives me the output of a day's attendance only (First IN & Last OUT).
Now, we would like to store the data in a separate table (or may be create a view)and would also like to insert next days' data in the same table, without deleting previous days records. We don't want to work with the main table i.e. History Table, since it has end numbers of rows and query through this table takes some time. We would like to use the new view for publishing attendance on a daily basis. The data can be pushed to the new table at a schedule time during night.

Request you to help me to modify the query.

SELECT * FROM
(SELECT a.link3,
REPLACE (CONVERT(VARCHAR(11),TIMESTAMP, 106),' ', '-') new_date,
MIN(a.TIMESTAMP) AS First_in,
MAX(a.TIMESTAMP) AS Last_Out
from History a
where REPLACE (CONVERT(VARCHAR(11),TIMESTAMP, 106),' ', '-') = '04-apr-2013'
GROUP BY a.link3, REPLACE (CONVERT(VARCHAR(11),TIMESTAMP, 106),' ', '-')
) A
INNER JOIN emp_sms_email b ON a.link3 = b.CardHolderID
where b.CardNumber like '%'
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros