Click here to Skip to main content
15,909,091 members
Home / Discussions / Database
   

Database

 
GeneralGenericOLEDB Pin
sjurmr19-Mar-05 11:20
sjurmr19-Mar-05 11:20 
GeneralSQL database protection Pin
Wimal Prasanna19-Mar-05 4:39
Wimal Prasanna19-Mar-05 4:39 
GeneralRe: SQL database protection Pin
Colin Angus Mackay19-Mar-05 10:32
Colin Angus Mackay19-Mar-05 10:32 
GeneralRe: SQL database protection Pin
Mike Dimmick19-Mar-05 23:08
Mike Dimmick19-Mar-05 23:08 
GeneralOR mapping tools And Object Broker pattern Pin
devvvy19-Mar-05 2:51
devvvy19-Mar-05 2:51 
GeneralSoundex In Ado.net Dataset Search Pin
Hemant Mane18-Mar-05 22:41
Hemant Mane18-Mar-05 22:41 
QuestionIIS Webhits via ADO.NET? Pin
harryteck18-Mar-05 13:39
harryteck18-Mar-05 13:39 
GeneralINNER JOIN Pin
HahnTech18-Mar-05 9:00
HahnTech18-Mar-05 9:00 
I’ve been working on this quire for a day now and can’t seem to figure it out.
Given theses tables: (if there is an error in the create table disregard it. This code is the simplest way I can describe the tables)
<br />
Create table Problem as (PID int Primary Key, <br />
                         POpenDate DateTime Not Null,<br />
                         Pclosed DateTime Not Null<br />
                         )on primary<br />
Create table Notes as (	NID int PrimaryKey,<br />
			PID int ForegnKey to Problem.PID,<br />
			NEditDate<br />
			)on primary


There is a one-to-many relationship between Problems and Notes.

I’m trying to select this:

Select  p.PID, p.POpenDate, n.NEditDate as ‘LastEditDate’, p.PclosedDate <br />
	Form Problems as p INNER JOIN Notes as n on p.PID = n.NID


Now because Notes keeps a record of all Edits to a Problem this select statement returns a record for every Edit since all edits must have a problem. I only want the most resent, or the closest date to now, returned.

A few things I’ve tried:
select DISTINCT ….. Doesn’t work they are all distinct because of the EditDate
select … group by p.PID Gave me: Server: Msg 8120, Level 16, State 1, Line 1
Column '_FieldName_' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Select top 1… Didn’t work only returns the Top one (well no kidding eh) I need the top 1 for each PID

I can’t change the design of the Db either.

Any Help would be Very much appreciated
Thank you,



Ronald Hahn, CNT - Computer Engineering Technologist

New Technologies Analyst

HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
GeneralRe: INNER JOIN Pin
HahnTech18-Mar-05 10:22
HahnTech18-Mar-05 10:22 
QuestionCan someone give me an advise for my application's database Pin
Blue_Skye18-Mar-05 6:31
Blue_Skye18-Mar-05 6:31 
QuestionWhich is better on webservice? Pin
WDI18-Mar-05 0:27
WDI18-Mar-05 0:27 
AnswerRe: Which is better on webservice? Pin
Hesham Amin18-Mar-05 2:13
Hesham Amin18-Mar-05 2:13 
Generaland - or statement Pin
WDI18-Mar-05 0:20
WDI18-Mar-05 0:20 
GeneralRe: and - or statement Pin
Colin Angus Mackay18-Mar-05 1:58
Colin Angus Mackay18-Mar-05 1:58 
GeneralRe: and - or statement Pin
WDI25-Mar-05 6:46
WDI25-Mar-05 6:46 
GeneralRe: and - or statement Pin
Colin Angus Mackay25-Mar-05 11:18
Colin Angus Mackay25-Mar-05 11:18 
GeneralRe: and - or statement Pin
Michael Potter18-Mar-05 6:01
Michael Potter18-Mar-05 6:01 
GeneralRe: and - or statement Pin
Michael Potter18-Mar-05 6:13
Michael Potter18-Mar-05 6:13 
GeneralRe: and - or statement Pin
WDI18-Mar-05 9:31
WDI18-Mar-05 9:31 
GeneralRe: and - or statement Pin
Michael Potter18-Mar-05 10:04
Michael Potter18-Mar-05 10:04 
Questionhow to call for update in two different databases? Pin
mijan17-Mar-05 19:47
mijan17-Mar-05 19:47 
AnswerRe: how to call for update in two different databases? Pin
Anonymous20-Mar-05 21:54
Anonymous20-Mar-05 21:54 
GeneralPage numbers Pin
Sebastien Lachance17-Mar-05 8:02
Sebastien Lachance17-Mar-05 8:02 
GeneralRe: Page numbers Pin
Michael Potter17-Mar-05 9:54
Michael Potter17-Mar-05 9:54 
Questionhow to add oledb connection in module by writing code Pin
sumit2117-Mar-05 7:42
sumit2117-Mar-05 7: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.