Click here to Skip to main content
15,902,939 members
Home / Discussions / Database
   

Database

 
AnswerRe: Dying on this query Pin
Krish - KP21-Jun-07 5:08
Krish - KP21-Jun-07 5:08 
AnswerRe: Dying on this query Pin
andyharman21-Jun-07 5:19
professionalandyharman21-Jun-07 5:19 
GeneralRe: Dying on this query Pin
Hulicat21-Jun-07 6:13
Hulicat21-Jun-07 6:13 
GeneralRe: Dying on this query Pin
andyharman22-Jun-07 0:40
professionalandyharman22-Jun-07 0:40 
GeneralRe: Dying on this query Pin
Hulicat22-Jun-07 2:02
Hulicat22-Jun-07 2:02 
AnswerRe: Dying on this query Pin
Michael Potter21-Jun-07 10:52
Michael Potter21-Jun-07 10:52 
GeneralRe: Dying on this query Pin
Hulicat21-Jun-07 13:23
Hulicat21-Jun-07 13:23 
GeneralRe: Dying on this query Pin
Michael Potter22-Jun-07 3:05
Michael Potter22-Jun-07 3:05 
Whoops, that is the problem with not having data to test with. Try this:
SELECT
    Opened, 
    [Total Open at Start], 
    (SELECT 
        COUNT(*) 
     FROM 
        dbo.job_ticket 
     WHERE 
        location_id = Source.location_id AND
        status_type_id like '[3,4,5]' AND 
        last_updated between @startdate and @enddate) AS [Total Open at End],
    (SELECT 
        COUNT(*) 
     FROM 
        dbo.job_ticket 
     WHERE 
        location_id = Source.location_id AND
        status_type_id like '[3,4,5]' AND 
        last_updated between @startdate and @enddate) - [Total Open at Start] AS [Total Closed], 
    Client, 
    [Average days open]
FROM
    (SELECT 
        l.location_id,
        l.location_name AS 'Client', 
        COUNT(*) AS 'Opened',
        SUM(CASE 
                WHEN status_type_id LIKE '[1,2,6,7]' THEN 1 
                ELSE 0 
            END) AS 'Total Open at Start', 
        AVG(datediff(d,report_date,getdate())) AS [Average days open]
     FROM 
        job_ticket j 
     INNER JOIN
        location l 
        ON (l.location_id = j.location_id)
     WHERE 
        report_date BETWEEN @startdate AND @enddate
     GROUP BY
        l.location_id,
        l.location_name) AS Source

GeneralRe: Dying on this query Pin
Hulicat22-Jun-07 16:06
Hulicat22-Jun-07 16:06 
QuestionProblem with special characters in SqlParameter Pin
chovdry21-Jun-07 4:10
chovdry21-Jun-07 4:10 
AnswerRe: Problem with special characters in SqlParameter Pin
Colin Angus Mackay21-Jun-07 4:41
Colin Angus Mackay21-Jun-07 4:41 
GeneralRe: Problem with special characters in SqlParameter Pin
chovdry21-Jun-07 5:02
chovdry21-Jun-07 5:02 
GeneralRe: Problem with special characters in SqlParameter Pin
Mike Dimmick21-Jun-07 5:49
Mike Dimmick21-Jun-07 5:49 
AnswerRe: Problem with special characters in SqlParameter Pin
Krish - KP21-Jun-07 5:20
Krish - KP21-Jun-07 5:20 
GeneralRe: Problem with special characters in SqlParameter Pin
Mike Dimmick21-Jun-07 5:38
Mike Dimmick21-Jun-07 5:38 
GeneralRe: Problem with special characters in SqlParameter Pin
Krish - KP21-Jun-07 6:01
Krish - KP21-Jun-07 6:01 
QuestionFormula Pin
ScottM121-Jun-07 2:01
ScottM121-Jun-07 2:01 
AnswerRe: Formula Pin
Colin Angus Mackay21-Jun-07 2:18
Colin Angus Mackay21-Jun-07 2:18 
GeneralRe: Formula Pin
ScottM121-Jun-07 2:42
ScottM121-Jun-07 2:42 
AnswerRe: Formula Pin
Michael Potter21-Jun-07 11:11
Michael Potter21-Jun-07 11:11 
GeneralRe: Formula Pin
ScottM121-Jun-07 19:27
ScottM121-Jun-07 19:27 
Questionmax two records........ Pin
Member 387988121-Jun-07 1:34
Member 387988121-Jun-07 1:34 
AnswerRe: max two records........ Pin
WhiteGirl2321-Jun-07 2:00
WhiteGirl2321-Jun-07 2:00 
GeneralRe: max two records........ Pin
ScottM121-Jun-07 2:10
ScottM121-Jun-07 2:10 
AnswerRe: max two records........ Pin
ScottM121-Jun-07 2:04
ScottM121-Jun-07 2:04 

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.