Click here to Skip to main content
15,912,329 members
Home / Discussions / Database
   

Database

 
AnswerRe: sql syntax Pin
Coding C#27-Nov-06 19:24
Coding C#27-Nov-06 19:24 
GeneralRe: sql syntax Pin
Arif Liminto27-Nov-06 20:26
professionalArif Liminto27-Nov-06 20:26 
GeneralRe: sql syntax Pin
asithangae27-Nov-06 21:20
asithangae27-Nov-06 21:20 
GeneralRe: sql syntax Pin
Colin Angus Mackay27-Nov-06 22:30
Colin Angus Mackay27-Nov-06 22:30 
GeneralRe: sql syntax Pin
Coding C#28-Nov-06 0:21
Coding C#28-Nov-06 0:21 
GeneralRe: sql syntax Pin
Paul Conrad28-Nov-06 13:40
professionalPaul Conrad28-Nov-06 13:40 
QuestionPostgreSQL, ODBC and transaction strange behavior Pin
Le Sourcier27-Nov-06 3:55
Le Sourcier27-Nov-06 3:55 
QuestionSQL Query - join or exists? Pin
Dewald27-Nov-06 3:26
Dewald27-Nov-06 3:26 
I'm hoping someone can help me with this query that I've been struggling with. I'll use an example to explain my problem.

Let's say I have a table named Orders with the following three fields:
CustID, OrderDescr and OrderDate

Now I want to select from this table the first order (oldest date) for each customer. In other words I want a resulting table that lists one entry for every unique CustID in Orders that shows the oldest order for that CustID.

I was hoping the following SQL query would do the trick but it doesn't.
SELECT * FROM Orders O1 WHERE exists<br />
(SELECT TOP 1 * from Orders O2 WHERE O1.CustID = O2.CustID AND O1.OrderDate = O2.OrderDate Order by OrderDate)


Alternatively I was thinking that doing an INNER JOIN with the table on itself there might be a way but I have as yet not been able to figure it out.
AnswerRe: SQL Query - join or exists? Pin
ednrgc27-Nov-06 3:33
ednrgc27-Nov-06 3:33 
GeneralRe: SQL Query - join or exists? Pin
Dewald27-Nov-06 4:05
Dewald27-Nov-06 4:05 
GeneralRe: SQL Query - join or exists? Pin
ednrgc27-Nov-06 4:08
ednrgc27-Nov-06 4:08 
GeneralRe: SQL Query - join or exists? Pin
Dewald27-Nov-06 4:21
Dewald27-Nov-06 4:21 
GeneralRe: SQL Query - join or exists? Pin
ednrgc27-Nov-06 9:15
ednrgc27-Nov-06 9:15 
AnswerRe: SQL Query - join or exists? Pin
Pete O'Hanlon27-Nov-06 9:16
mvePete O'Hanlon27-Nov-06 9:16 
AnswerRe: SQL Query - join or exists? Pin
Michael Potter27-Nov-06 10:16
Michael Potter27-Nov-06 10:16 
QuestionSQL help needed Pin
jegastar27-Nov-06 2:06
jegastar27-Nov-06 2:06 
AnswerRe: SQL help needed Pin
Pete O'Hanlon27-Nov-06 2:15
mvePete O'Hanlon27-Nov-06 2:15 
AnswerRe: SQL help needed Pin
jegastar27-Nov-06 2:28
jegastar27-Nov-06 2:28 
GeneralRe: SQL help needed Pin
jegastar27-Nov-06 2:30
jegastar27-Nov-06 2:30 
GeneralRe: SQL help needed Pin
Rob Graham27-Nov-06 2:55
Rob Graham27-Nov-06 2:55 
Question"trigger" Pin
ravikiranreddydharmannagari26-Nov-06 20:16
ravikiranreddydharmannagari26-Nov-06 20:16 
AnswerRe: "trigger" Pin
Pete O'Hanlon27-Nov-06 1:41
mvePete O'Hanlon27-Nov-06 1:41 
AnswerRe: "trigger" Pin
Eric Dahlvang27-Nov-06 3:23
Eric Dahlvang27-Nov-06 3:23 
QuestionConnecting Problem [modified] Pin
firebow300726-Nov-06 19:40
firebow300726-Nov-06 19:40 
AnswerRe: Connecting Problem Pin
Paul Conrad25-Dec-06 18:22
professionalPaul Conrad25-Dec-06 18:22 

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.