Click here to Skip to main content
15,897,334 members
Home / Discussions / Database
   

Database

 
GeneralRe: how to insert data from one table to other two diferent tables using SQL query Pin
khalidd14-Sep-08 21:46
khalidd14-Sep-08 21:46 
QuestionSELECT COUNT returns 2 answers. Pin
Sunset Towers12-Sep-08 12:36
Sunset Towers12-Sep-08 12:36 
AnswerRe: SELECT COUNT returns 2 answers. Pin
Eslam Afifi12-Sep-08 12:58
Eslam Afifi12-Sep-08 12:58 
QuestionDupicate [modified] Pin
Bassam Saoud12-Sep-08 5:52
Bassam Saoud12-Sep-08 5:52 
GeneralRe: Dupicate Pin
Eslam Afifi13-Sep-08 4:47
Eslam Afifi13-Sep-08 4:47 
GeneralRe: Dupicate Pin
Bassam Saoud13-Sep-08 11:51
Bassam Saoud13-Sep-08 11:51 
GeneralRe: Dupicate Pin
Eslam Afifi13-Sep-08 12:54
Eslam Afifi13-Sep-08 12:54 
QuestionMore advice on a slighltly more complex select statement Pin
Steven J Jowett12-Sep-08 3:40
Steven J Jowett12-Sep-08 3:40 
tblVisitor is a list of visitors that is linked to a record in the tblEmployee table and what I need to do is select the last visitor based on the ClockedIn column, which is a DateTime.

So my question is how do I insert this :-

SELECT TOP 1 * FROM tblVisitors WHERE intEmpID = tblEmployee.intEmpID  ORDER BY ClockedIn DESC


into this SELECT statement :-

SELECT     TOP (100) PERCENT employee.intEmpID AS ID, employee.strEmpID AS CardReference, 
		CASE WHEN Employee.intStatus = 0 THEN 
			NULL 
        ELSE 
			Employee.strTitle + ' ' + Employee.strForename + ' ' + Employee.strSurname 
		END AS Visitor, 
		Visitor.Company, 
        Visitor.VisitorCardEmpId AS ResponsiblePersonnel, 
		CASE Employee.intStatus 
			WHEN 1 THEN
				-1 
			ELSE 
				0 
		END AS ClockedIn,
		CASE WHEN Employee.intStatus = 0 THEN
			NULL
		ELSE
			Visitor.TimeIn
		END As ArrivalTime
	FROM         tblEmployee AS employee LEFT OUTER JOIN
                      dbo.tblVisitors AS Visitor ON Visitor.intEmpId = employee.intEmpID 
	WHERE     (employee.strEmpID LIKE 'V%')
	ORDER BY CardReference


So that the result is one row pre employee.

Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.

AnswerRe: More advice on a slighltly more complex select statement Pin
Ashfield12-Sep-08 4:23
Ashfield12-Sep-08 4:23 
GeneralRe: More advice on a slighltly more complex select statement Pin
Steven J Jowett12-Sep-08 4:45
Steven J Jowett12-Sep-08 4:45 
GeneralRe: More advice on a slighltly more complex select statement Pin
Ashfield12-Sep-08 8:34
Ashfield12-Sep-08 8:34 
QuestionSQL Linked Server/Web Service Question Pin
dhbaer12-Sep-08 3:40
dhbaer12-Sep-08 3:40 
AnswerRe: SQL Linked Server/Web Service Question Pin
Steven J Jowett12-Sep-08 4:05
Steven J Jowett12-Sep-08 4:05 
QuestionAdvice on Select query please Pin
Steven J Jowett12-Sep-08 0:32
Steven J Jowett12-Sep-08 0:32 
AnswerRe: Advice on Select query please Pin
dojohansen12-Sep-08 1:17
dojohansen12-Sep-08 1:17 
AnswerRe: Advice on Select query please Pin
Ashfield12-Sep-08 1:39
Ashfield12-Sep-08 1:39 
GeneralRe: Advice on Select query please Pin
Steven J Jowett12-Sep-08 2:18
Steven J Jowett12-Sep-08 2:18 
GeneralRe: Advice on Select query please Pin
Ashfield12-Sep-08 4:16
Ashfield12-Sep-08 4:16 
QuestionSelect Exact Day Pin
Agweet11-Sep-08 22:16
Agweet11-Sep-08 22:16 
AnswerRe: Select Exact Day Pin
dojohansen12-Sep-08 1:21
dojohansen12-Sep-08 1:21 
GeneralRe: Select Exact Day Pin
Agweet12-Sep-08 1:59
Agweet12-Sep-08 1:59 
QuestionNeed some help with deleting process Pin
MarkB77711-Sep-08 22:15
MarkB77711-Sep-08 22:15 
AnswerRe: Need some help with deleting process Pin
Blue_Boy11-Sep-08 22:22
Blue_Boy11-Sep-08 22:22 
GeneralRe: Need some help with deleting process Pin
MarkB77711-Sep-08 23:17
MarkB77711-Sep-08 23:17 
GeneralRe: Need some help with deleting process Pin
Blue_Boy11-Sep-08 23:42
Blue_Boy11-Sep-08 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.