Click here to Skip to main content
15,888,454 members
Home / Discussions / Database
   

Database

 
GeneralRe: Question about Oracle tools Pin
Chris Meech5-May-04 7:44
Chris Meech5-May-04 7:44 
GeneralRe: Question about Oracle tools Pin
Keith Vitali5-May-04 8:59
Keith Vitali5-May-04 8:59 
GeneralRe: Question about Oracle tools Pin
Chris Meech5-May-04 9:30
Chris Meech5-May-04 9:30 
GeneralRe: Question about Oracle tools Pin
Keith Vitali5-May-04 10:11
Keith Vitali5-May-04 10:11 
GeneralMax and Where Pin
OmegaSupreme5-May-04 1:28
OmegaSupreme5-May-04 1:28 
GeneralRe: Max and Where Pin
Mike Dimmick5-May-04 1:54
Mike Dimmick5-May-04 1:54 
GeneralRe: Max and Where Pin
WoutL5-May-04 1:57
WoutL5-May-04 1:57 
GeneralRe: Max and Where Pin
OmegaSupreme5-May-04 3:28
OmegaSupreme5-May-04 3:28 
Thank you both for your help.

I tried adding the HAVING clause instead of WHERE and got the following errors:

Column 'BookingDate.bookingDate' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.
Column 'Booking.fkChannelId' is invalid in the HAVING clause because it is not contained in either an aggregate function or the GROUP BY clause.


The tables I have are as follows each with a one to many relationship with the following table:

Ad
	pkAdId
Booking
	pkBookingId
	fkAdId
BookingDate
	pkBookingDateId
	fkBookingId
BookingHour
	pkBookingHourId
	fkBookingDateId


and heres the query as it stands :

SELECT DISTINCT 
		                      Ad.pkAdId, Ad.fileName, Ad.name,
 Ad.length, Ad.lastUpdated, MAX(BookingDate.bookingDate) AS MaxDate, MIN(BookingDate.bookingDate) AS MinDate, 
		                      AVG(BookingHour.bookedSlots + BookingHour.bonusSlots) AS AverageSlots
		FROM         Ad INNER JOIN
		                      Booking ON Ad.pkAdId = Booking.fkAdId INNER JOIN
		                      BookingDate ON Booking.pkBookingId = BookingDate.fkBookingId INNER JOIN
		                      BookingHour ON BookingDate.pkBookingDateId = BookingHour.fkBookingDateId
		
		WHERE  (BookingDate.bookingDate >= @startDate) 
		AND (BookingDate.bookingDate <= @endDate) 
		AND (Booking.fkChannelId = @channelId) AND
		GROUP BY Ad.pkAdId, Ad.fileName, Ad.name, Ad.length, Ad.lastUpdated
		ORDER BY Ad.fileName



Try not! Do or do not, there is no try. - Master Yoda
GeneralRe: Max and Where Pin
WoutL5-May-04 3:50
WoutL5-May-04 3:50 
GeneralRe: Max and Where Pin
OmegaSupreme5-May-04 4:00
OmegaSupreme5-May-04 4:00 
GeneralRe: Max and Where Pin
WoutL5-May-04 4:06
WoutL5-May-04 4:06 
GeneralRe: Max and Where Pin
OmegaSupreme5-May-04 4:39
OmegaSupreme5-May-04 4:39 
GeneralMore on DataSets Pin
normanordas4-May-04 23:50
normanordas4-May-04 23:50 
GeneralRe: More on DataSets Pin
Mike Dimmick5-May-04 1:57
Mike Dimmick5-May-04 1:57 
GeneralMSDE Usage Pin
Roger Wright4-May-04 18:45
professionalRoger Wright4-May-04 18:45 
GeneralRe: MSDE Usage Pin
Maxwell Chen4-May-04 18:59
Maxwell Chen4-May-04 18:59 
GeneralRe: MSDE Usage Pin
normanordas4-May-04 23:59
normanordas4-May-04 23:59 
GeneralComparing two tables using C#, ADO.NET Pin
Brett Slaski4-May-04 8:24
Brett Slaski4-May-04 8:24 
GeneralCrystal Reports Pin
Mr. Cully4-May-04 1:09
Mr. Cully4-May-04 1:09 
GeneralRe: Crystal Reports Pin
Mr. Cully4-May-04 5:09
Mr. Cully4-May-04 5:09 
Generaldetach database Pin
Dpriya3-May-04 23:58
Dpriya3-May-04 23:58 
GeneralRe: detach database Pin
Mazdak4-May-04 5:38
Mazdak4-May-04 5:38 
QuestionHow I access database through a Map Network drive? Pin
ATC3-May-04 8:13
ATC3-May-04 8:13 
AnswerRe: How I access database through a Map Network drive? Pin
Mike Ellison4-May-04 8:31
Mike Ellison4-May-04 8:31 
Questionhow to put an image in sql database Pin
Member 7402202-May-04 11:15
Member 7402202-May-04 11:15 

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.