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

Database

 
GeneralDelete question Pin
Tom Wright16-Feb-05 8:57
Tom Wright16-Feb-05 8:57 
GeneralRe: Delete question Pin
Mike Dimmick17-Feb-05 1:25
Mike Dimmick17-Feb-05 1:25 
GeneralRe: Delete question Pin
Tom Wright17-Feb-05 4:22
Tom Wright17-Feb-05 4:22 
GeneralRe: Delete question Pin
Rob Graham17-Feb-05 7:39
Rob Graham17-Feb-05 7:39 
GeneralDataGrid Columns Pin
numbrel16-Feb-05 5:40
numbrel16-Feb-05 5:40 
GeneralRe: DataGrid Columns Pin
Just Greeky Creek16-Feb-05 21:15
Just Greeky Creek16-Feb-05 21:15 
GeneralRe: DataGrid Columns Pin
numbrel17-Feb-05 3:06
numbrel17-Feb-05 3:06 
GeneralSQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 3:07
Richard Parsons16-Feb-05 3:07 
Thanks for at least looking. I know there is a SQL Guru out there just waiting to help unlearned and ignorant programmers

I have two tables which are as indicated:
Table1
IDNO : RefID
01 : 100
02 : 200
03 : 300

Table2
IDNO : RefID : Code : SmallDateTimeStamp
01 : 100 : a : 1/1/2005 1:01:00
02 : 100 : b : 1/1/2005 1:02:00
03 : 100 : c : 1/2/2005 2:03:00
04 : 100 : d : 1/2/2005 3:00:00
05 : 100 : f : 1/3/2005 1:00:00
06 : 200 : a : 1/1/2005 4:55:00
07 : 200 : c : 1/1/2005 4:59:00
08 : 200 : f : 1/1/2005 5:02:00
09 : 300 : a : 1/2/2005 1:00:00
10 : 300 : c : 1/2/2005 2:00:00
11 : 300 : d : 1/2/2005 3:00:00
12 : 300 : f : 1/2/2005 4:00:00

My problem is that I need to select the IDNOs from Table1 where the same RefID in Table2 has a last record of “f” and a second to last record of “c”
EDIT: New task, I now assume all record in table1 have a last record of 'f' so all I need to get now is where table2 has a 2nd to last record of 'c'

Currently I'm getting all the rows from table1 and looping through them in code to do another query on table2. While this solution works it is slow and I believe there is another way to do this better and faster.

Thanks for any help you can offer.
-Richard
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
Michael Potter16-Feb-05 3:24
Michael Potter16-Feb-05 3:24 
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 6:50
Richard Parsons16-Feb-05 6:50 
GeneralTest data script Pin
Richard Parsons16-Feb-05 6:51
Richard Parsons16-Feb-05 6:51 
GeneralEDIT: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 7:27
Richard Parsons16-Feb-05 7:27 
GeneralRe: EDIT: SQL Guru challenge :) Or just a simple query question Pin
Michael Potter16-Feb-05 8:49
Michael Potter16-Feb-05 8:49 
GeneralRe: EDIT: SQL Guru challenge :) Or just a simple query question Pin
Richard Parsons16-Feb-05 11:34
Richard Parsons16-Feb-05 11:34 
GeneralRe: SQL Guru challenge :) Or just a simple query question Pin
NassosReyzidis10-Mar-05 1:11
NassosReyzidis10-Mar-05 1:11 
Generalprob in sp Pin
amalatsliit15-Feb-05 16:46
amalatsliit15-Feb-05 16:46 
GeneralRe: prob in sp Pin
Rob Graham16-Feb-05 15:59
Rob Graham16-Feb-05 15:59 
GeneralRe: prob in sp Pin
amalatsliit16-Feb-05 19:33
amalatsliit16-Feb-05 19:33 
GeneralRe: prob in sp Pin
Mike Dimmick17-Feb-05 1:31
Mike Dimmick17-Feb-05 1:31 
GeneralRe: prob in sp Pin
amalatsliit17-Feb-05 16:01
amalatsliit17-Feb-05 16:01 
GeneralCasting error when passing a strongly typed dataset from a Webservice Pin
dazzler215-Feb-05 16:41
dazzler215-Feb-05 16:41 
GeneralRe: Casting error when passing a strongly typed dataset from a Webservice Pin
dazzler215-Feb-05 20:47
dazzler215-Feb-05 20:47 
Generalprob with sp return value Pin
amalatsliit15-Feb-05 15:55
amalatsliit15-Feb-05 15:55 
GeneralRe: prob with sp return value Pin
Scott Serl16-Feb-05 8:52
Scott Serl16-Feb-05 8:52 
GeneralRe: prob with sp return value Pin
amalatsliit16-Feb-05 15:17
amalatsliit16-Feb-05 15:17 

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.