Click here to Skip to main content
15,907,225 members
Home / Discussions / Database
   

Database

 
GeneralRe: Audit Trail : Single table for all users or multiple table per user Pin
musefan6-Mar-11 23:36
musefan6-Mar-11 23:36 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
Eddy Vluggen7-Mar-11 0:15
professionalEddy Vluggen7-Mar-11 0:15 
AnswerRe: Audit Trail : Single table for all users or multiple table per user Pin
Wendelius7-Mar-11 1:52
mentorWendelius7-Mar-11 1:52 
QuestionUpgrading MSDE SP4 to SQL 2008 Express R2 Pin
Elsie6-Mar-11 19:46
Elsie6-Mar-11 19:46 
QuestionSQL Help - sum items based on max but also smaller than...? Pin
GlobX6-Mar-11 17:09
GlobX6-Mar-11 17:09 
AnswerRe: SQL Help - sum items based on max but also smaller than...? Pin
Wendelius7-Mar-11 7:40
mentorWendelius7-Mar-11 7:40 
GeneralRe: SQL Help - sum items based on max but also smaller than...? [modified] Pin
GlobX7-Mar-11 12:12
GlobX7-Mar-11 12:12 
GeneralRe: SQL Help - sum items based on max but also smaller than...? Pin
Wendelius7-Mar-11 18:37
mentorWendelius7-Mar-11 18:37 
Hi,

I noticed that you solved the problem by using cursor, which is fine but fot performance reasons I think that if we could find a set-based solution it'd be best.

So if I understood correctly you need each individual ID in your result set and sums for them, so could the query be something like:
SELECT d.Day,
       d.[Day Of Year],
       (SELECT SUM(Points)
        FROM   #tickets t
        WHERE  t.[Changed Date] <= d.[Day Of Year]
        AND    t.Id = sub1.Id) AS Points
FROM #sprintDays d, 
     (SELECT DISTINCT t.Id
      FROM #tickets t) sub1


Just correct me if If I'm going to wrong direction.
The need to optimize rises from a bad design.My articles[^]

AnswerRe: SQL Help - sum items based on max but also smaller than...? Pin
GlobX7-Mar-11 13:05
GlobX7-Mar-11 13:05 
Questioncopy data from 1 table to another table Pin
bapu28895-Mar-11 6:07
bapu28895-Mar-11 6:07 
AnswerRe: copy data from 1 table to another table Pin
Mycroft Holmes5-Mar-11 12:07
professionalMycroft Holmes5-Mar-11 12:07 
AnswerRe: copy data from 1 table to another table Pin
PIEBALDconsult5-Mar-11 14:48
mvePIEBALDconsult5-Mar-11 14:48 
QuestionRe: copy data from 1 table to another table Pin
bapu28895-Mar-11 19:57
bapu28895-Mar-11 19:57 
QuestionRead only ADO connection still allows writing to database? Pin
PJ Arends4-Mar-11 17:54
professionalPJ Arends4-Mar-11 17:54 
AnswerRe: Read only ADO connection still allows writing to database? Pin
Mycroft Holmes4-Mar-11 19:59
professionalMycroft Holmes4-Mar-11 19:59 
GeneralRe: Read only ADO connection still allows writing to database? Pin
PJ Arends6-Mar-11 10:26
professionalPJ Arends6-Mar-11 10:26 
GeneralRe: Read only ADO connection still allows writing to database? Pin
Mycroft Holmes6-Mar-11 11:42
professionalMycroft Holmes6-Mar-11 11:42 
GeneralRe: Read only ADO connection still allows writing to database? Pin
PJ Arends6-Mar-11 17:51
professionalPJ Arends6-Mar-11 17:51 
GeneralRe: Read only ADO connection still allows writing to database? Pin
Mycroft Holmes6-Mar-11 18:01
professionalMycroft Holmes6-Mar-11 18:01 
QuestionUpdating Columns Pin
whatsa3-Mar-11 14:14
whatsa3-Mar-11 14:14 
AnswerRe: Updating Columns Pin
Luc Pattyn3-Mar-11 14:24
sitebuilderLuc Pattyn3-Mar-11 14:24 
GeneralRe: Updating Columns Pin
whatsa17-Mar-11 10:07
whatsa17-Mar-11 10:07 
AnswerRe: Updating Columns Pin
jschell3-Mar-11 15:27
jschell3-Mar-11 15:27 
GeneralRe: Updating Columns Pin
PIEBALDconsult3-Mar-11 16:34
mvePIEBALDconsult3-Mar-11 16:34 
QuestionSQL Server Authentication issue - Fixed, but I don't understand why Pin
gantww3-Mar-11 5:55
gantww3-Mar-11 5:55 

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.