Re: Combine SQL statement

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: spamless (jejorstad_at_yahoo.com.(spamless))
Date: 10/20/04


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
> >>
> >>
> >>
>
>
>



Relevant Pages

  • Re: X3SAT Question
    ... Given a collection of clauses, ... Just produce a reduced X3SAT instance that is unsatisfiable. ... The sum of weights of vertices in the VC must equal 2m. ... add "abg" to the neighbor sets of the remaining vertices. ...
    (comp.theory)
  • Re: Like
    ... those look like WHERE clauses. ... summarized values. ... Doug Steele, Microsoft Access MVP ... (no e-mails, please!) ...
    (microsoft.public.access.queries)
  • Re: Like
    ... those look like WHERE clauses. ... summarized values. ... usenet at dfenton dot com http://www.dfenton.com/DFA/ ...
    (microsoft.public.access.queries)
  • RE: Joining tables
    ... AMB ... > I want to pull back all of the results in T2 and sum the totals, ... > How can I sum my four colums but only get results for one Date in the T1 ...
    (microsoft.public.sqlserver.programming)