SQL Select SUM question
Dave Addey
listmail1 at dsl.pipex.com
Wed Sep 27 13:18:24 CDT 2006
Hi Ruslan,
> TIP:
>
> SELECT * is not very safe, because if future you change
> fields in tables your old code can be broken.
I found it was quicker to SELECT * than it was to build a list of the fields
I needed. I have complete control over my table structure, so this
shouldn't cause a problem in the future. Thanks for the tip, though!
>> This gives a database error:
>>
>> ³In the SELECT clause you an use only fields listed in the GROUP BY and
>> aggregate functions.²
>
> Right. SQL Standard
Okay.
>> Can I do the general ³SELECT Tracks.*², and also the ³SELECT SUM()², as part
>> of the same query? If so:
>
> no
So I think I need to do this instead, as a separate query:
SELECT SUM(Tracks.Duration) FROM Tracks, PlaylistTracks WHERE
PlaylistTracks.TrackUniqueIDPtr = Tracks.UniqueID AND
PlaylistTracks.PlaylistUniqueIDPtr = 22731
That seems to work - thanks!
Dave.
More information about the Valentina
mailing list