Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

SUM and CASE query

user10256838Aug 28 2014 — edited Aug 29 2014

Hi. Im not expert in SQL and i work on a query that return separable lines, but i want sum all records.

This is my query

select    (CASE

              WHEN d.cd_procedimento = 40901394 THEN (select count(*)+3 from DUAL )

            ELSE (select count(*) from dual) 

                       

                        END) AS qt_laudo

from    laudo_paciente a,

        prescr_procedimento b,

        atendimento_paciente_v c,

        procedimento d

where a.nr_prescricao  = b.nr_prescricao

and a.nr_seq_prescricao = b.nr_sequencia

and  a.nr_atendimento = c.nr_atendimento

and  b.cd_procedimento = d.cd_procedimento

and  b.ie_origem_proced = d.ie_origem_proced

and     a.nr_prescricao in (3496038, 3509479)

GROUP BY a.nr_sequencia,d.CD_PROCEDIMENTO

My query return:

QT_LAUDO

1

4

1

1

1

1

1

I would like that return like that:

QT_LAUDO

10

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2014
Added on Aug 28 2014
14 comments
3,256 views