Re: Combine SQL statement
From: spamless (jejorstad_at_yahoo.com.(spamless))
Date: 10/20/04
- Next message: Dan Guzman: "Re: text vs varchar"
- Previous message: Gert E.R. Drapers: "Re: SQLDMO"
- In reply to: Aleks: "Re: Combine SQL statement"
- Next in thread: Aleks: "Re: Combine SQL statement"
- Reply: Aleks: "Re: Combine SQL statement"
- Reply: Aleks: "Re: Combine SQL statement"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 19 Oct 2004 18:13:02 -0700
>From 1:00pm today:
Not tested, but something along these lines:
--case the parts of the WHERE clauses that were differente from to 0 or 1
and them sum them
select sum( case when (Lastmodified IS NOT NULL AND Dateinitiated IS NOT
NULL) then 1 else 0 end)
/
count(activityId) as [Actotcompleted/AcTotNum]
from dbo.Activities
where caseId = 24
and ActType = 'HISTORY'
"Aleks" wrote:
> There seems to be something wrong with my reader .. I don't see any previous
> answer to this ... can you paste it here ?
>
>
> "Alejandro Mesa" <AlejandroMesa@discussions.microsoft.com> wrote in message
> news:14B1DDEB-193C-4417-A3FB-293A4D5870F6@microsoft.com...
> > Before posting again the same question or problem it will be a good idea
> > to
> > check the previous one.
> >
> > THIS QUESTION WAS ALREADY ANSWERED
> >
> >
> >
> > AMB
> >
> > "Aleks" wrote:
> >
> >> I am trying to combine two sql statements to get just one result, right
> >> now
> >> I have:
> >>
> >> SELECT Count (ActivityId) AS ActTotNum
> >> FROM dbo.Activities
> >> WHERE CaseId = MMColParam and ActType ='HISTORY'
> >>
> >> Which gives result: ActTotNum = 14
> >>
> >> SELECT Count (ActivityId) AS ActCompleted
> >> FROM dbo.Activities
> >> WHERE CaseId = MMColParam and ActType ='HISTORY'AND (a.Lastmodified IS
> >> NOT
> >> NULL AND a.Dateinitiated IS NULL)
> >>
> >> Which gives result: ActCompleted = 4
> >>
> >> I need one statements that gives me: 4/14, that is ActCompleted /
> >> ActTotNum
> >>
> >> How can I do this ?
> >>
> >> Help is greately appreciated.
> >>
> >> Aleks
> >>
> >>
> >>
>
>
>
- Next message: Dan Guzman: "Re: text vs varchar"
- Previous message: Gert E.R. Drapers: "Re: SQLDMO"
- In reply to: Aleks: "Re: Combine SQL statement"
- Next in thread: Aleks: "Re: Combine SQL statement"
- Reply: Aleks: "Re: Combine SQL statement"
- Reply: Aleks: "Re: Combine SQL statement"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|