Click here to Skip to main content
15,895,256 members
Home / Discussions / Database
   

Database

 
GeneralRe: @@trancount problem Pin
Hesham Amin26-May-04 21:36
Hesham Amin26-May-04 21:36 
GeneralNetworked SQL DB Pin
Jamie Kenyon25-May-04 13:39
Jamie Kenyon25-May-04 13:39 
GeneralRe: Networked SQL DB Pin
Garth J Lancaster26-May-04 13:00
professionalGarth J Lancaster26-May-04 13:00 
GeneralSQL Nested queries syntax probs Pin
partt25-May-04 6:48
partt25-May-04 6:48 
GeneralRe: SQL Nested queries syntax probs Pin
Michael Potter25-May-04 11:25
Michael Potter25-May-04 11:25 
GeneralRe: SQL Nested queries syntax probs Pin
partt26-May-04 3:56
partt26-May-04 3:56 
GeneralRe: SQL Nested queries syntax probs Pin
partt26-May-04 3:57
partt26-May-04 3:57 
GeneralRe: SQL Nested queries syntax probs Pin
Michael Potter26-May-04 6:43
Michael Potter26-May-04 6:43 
(1) Now I think I understand your logic:

Give me everyone who has any ScheduleStamp <= @DD and does not have have a ScheduleStamp > @DD. Your original query is just not eliminating invalid Testers (ScheduleStamp > @DD).


(2) Find the people who have a schedule stamp after to @DD.

SELECT tTester.TesterID
FROM tTester
INNER JOIN tResultQue
     ON (tTester.TesterID = tResultQue.TesterID)
INNER JOIN tGroup
     ON (tResultQue.GroupID = tGroup.GroupID)
WHERE tGroup.ScheduleStamp > @DD
GROUP BY tTester.TesterID


(3) Add it to the WHERE clause.

CREATE PROCEDURE usp_tp_GetPKCall
(
    @SexID char,
    @RaceID char,
    @LBirth datetime,
    @UBirth datetime,
    @SiteID varchar(5), 
    @DD datetime
)
AS

IF @SexID = '*' AND
   @RaceID <> '*' AND 
   @SiteID <> '90000'
BEGIN

    SELECT 
        tGroup.ScheduleStamp, 
        tResultQue.TesterID, 
        tTester.LastName,
        tTester.FirstName, 
        tTester.WorkNo, 
        tTester.WorkExtension, 
        tTester.HomeNo,
        tTester.SexID, 
        tTester.Birth, 
        tTester.RaceID, 
        tTester.SiteID
    FROM tGroup 
    INNER JOIN tResultQue 
        ON (tGroup.GroupID = tResultQue.GroupID)
    INNER JOIN tTester 
        ON (tResultQue.TesterID = tTester.TesterID)
    WHERE tTester.RaceID = @RaceID AND 
        tTester.Birth >= @LBirth AND 
        tTester.Birth <= @UBirth AND 
        tTester.SiteID = @SiteID AND 
        tGroup.ScheduleStamp <= @DD AND
        tTester.TesterID NOT IN 
            (SELECT tTester.TesterID
            FROM tTester
            INNER JOIN tResultQue
                ON (tTester.TesterID = tResultQue.TesterID)
            INNER JOIN tGroup
                ON (tResultQue.GroupID = tGroup.GroupID)
            WHERE tGroup.ScheduleStamp > @DD
            GROUP BY tTester.TesterID)

END

GO 

GeneralRe: SQL Nested queries syntax probs Pin
partt26-May-04 7:50
partt26-May-04 7:50 
GeneralRe: SQL Nested queries syntax probs Pin
Michael Potter26-May-04 9:07
Michael Potter26-May-04 9:07 
GeneralRe: SQL Nested queries syntax probs Pin
partt26-May-04 9:36
partt26-May-04 9:36 
GeneralRe: SQL Nested queries syntax probs Pin
Michael Potter26-May-04 9:44
Michael Potter26-May-04 9:44 
GeneralRe: SQL Nested queries syntax probs Pin
partt26-May-04 10:12
partt26-May-04 10:12 
GeneralAttach SQL 2000 mdf on MSDE 2000 Pin
Aryo Handono25-May-04 4:17
professionalAryo Handono25-May-04 4:17 
GeneralRe: Attach SQL 2000 mdf on MSDE 2000 Pin
Hesham Amin25-May-04 23:55
Hesham Amin25-May-04 23:55 
GeneralRe: Attach SQL 2000 mdf on MSDE 2000 Pin
RichardGrimmer26-May-04 4:18
RichardGrimmer26-May-04 4:18 
GeneralNew Row with Id Pin
Anonymous25-May-04 4:15
Anonymous25-May-04 4:15 
GeneralRe: New Row with Id Pin
Michael Potter25-May-04 11:35
Michael Potter25-May-04 11:35 
GeneralProblem about MSDE installation Pin
wk_vigorous25-May-04 0:47
wk_vigorous25-May-04 0:47 
GeneralRe: Problem about MSDE installation Pin
RichardGrimmer26-May-04 4:23
RichardGrimmer26-May-04 4:23 
Generaloptimize this query Pin
varun8025-May-04 0:25
varun8025-May-04 0:25 
GeneralRe: optimize this query Pin
Grimolfr25-May-04 3:31
Grimolfr25-May-04 3:31 
GeneralRe: optimize this query Pin
varun8025-May-04 19:34
varun8025-May-04 19:34 
GeneralRe: optimize this query Pin
Grimolfr26-May-04 4:42
Grimolfr26-May-04 4:42 
Generalquery inside a dataset Pin
fuel2run24-May-04 21:27
fuel2run24-May-04 21:27 

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.