How to get a sum of the result?

I want to get the results to display the records only once if
I have the same case number.
This is my query.
SELECT distinct c.case_number,
c.bank_name,
i.first_name,
i.last_name,
it.id_name,
i.id_number1,
i.date_of_birth,
i.country_of_birth,
(select count(*) from #application.db#.anc_comments ac
join #application.db#.anc_hit h on ac.hit = h.hit_id
join #application.db#.anc_individual i on i.individual_key =
ac.individual_key
where i.case_number = c.case_number and
convert(integer,h.hit_code_value) > 0) as num_hits
FROM #application.db#.anc_case c
LEFT OUTER JOIN #application.db#.anc_individual i
on c.case_number = i.case_number
LEFT OUTER JOIN #application.db#.anc_id_type it on
i.id_type1 = it.id_class
left outer join #application.db#.anc_agency_response r
on i.individual_key = r.individual_key
WHERE (DATEDIFF(day, r.name_check_sent, getdate()) <= 90
or r.name_check_sent is null)
and (c.completed <> 'Yes' )
order by #url.sort#
My result displays the same case number more then onces for
some Case numbers. How do I make my query to combine or only
display the Case number once.
Case Number Bank Name
111-11-456456 AB Bank Name 2
11-11-09-14.001 AB Bank name 3
11-111-1114 AB Bank name 4
94-10-01-06.002 Citizens Bancorporation, Inc.
94-10-01-06.002 Citizens Bancorporation, Inc.
94-10-01-06.002 Citizens Bancorporation, Inc.
94-10-01-06.002 Citizens Bancorporation, Inc.
94-10-01-06.002 Citizens Bancorporation, Inc.
06-11-09-14.999 Kenco Bancshares, Inc.
Thanks for your assistance

Perhaps because you are using an OUTER JOIN - anytime the
entire set of selected columns is not distinct you will get another
row. Distinct applies to the entire row not just the case number.
Phil

Similar Messages

  • How to get a question in the course placed anywhere in the course and does not appear in the quiz result or total number of questions. Pretest would work except it can't go anywhere in the course (at least for me it can't)

    How to get a question in the course placed anywhere in the course and does not appear in the quiz result or total number of questions. Pretest would work except it can't go anywhere in the course (at least for me it can't)

    Use a normal question, and do not add the score to the total score. That will give you a correct score at the end. But the total number of questions, that system variable will still take into account all questions. You'll need a user variable, and calculate its value by subtracting 1 from the system variable cpQuizInfoTotalQuestionsPerProject. Same for the progress indicator if you want to show it?
    Customized Progress Indicator - Captivate blog
    If you want to allow Review, you'll have to tweak as well. You didn't specify the version, and all those questions I now mentioned.
    And my approach, since you talk about only one question: create a custom question, because you'll have total control then.

  • How to get different sum value by different types of record in sql server

    Hi,I have my query result like below
    AppID       LabType      DiaType      LabPrice    DiaPrice
      1                
    a               
    b               100          1000
      1                 a               
    cc              100          1000
      1                
    aa              b               100          1000
      1                 aa              cc             
    100          1000
      1                
    aaa            b               100          1000
      1                 aaa            cc              100         
    1000
    from this query
    select
    app.AppointmentId,
    lr.LabPrice,
    lt.LabCategoryType,
    drt.DiagnosisReportType,
        dr.DiaPrice as diaprice,
         from Appointment app
        left join DiagnosisReport dr on app.AppointmentId=dr.AppointmentId
        left join DiagnosisReportType drt on dr.DiagnosisReportTypeId=drt.DiagnosisReportTypeId
        left join LabCategoryReport lr on lr.AppointmentId=app.AppointmentId
        left join LabCategoryType lt on lt.LabCategoryTypeId=lr.LabCategoryTypeId
        where app.DeleteStatus='N'
        and app.AppointmentId='MLM-Appointment-60314748311012015'
        and dr.DeleteStatus='N'
        and lr.DeleteStatus='N'
    But I want following one line result by getting two sum result for 3 different types of Lab and 2 different
    type of Dia.
    AppID       LabPrice    DiaPrice
      1               300          2000
    Please, can anyone give me any idea or help how to get only one record query result.
    Thanks in advanced.
    Superman

    Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You failed. You should follow ISO-8601 rules for displaying temporal
    data. We need to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for: 
    https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
    >> I have my query result like below <<
    So you show us a result and expect that we can guess! Wow! We are magical! Did you ever read Douglas Adams? The answer is 42! Now find 
    the question. 
    Also, you have things like “lab_category_type” in this code. Is it a category or a type? In a valid data model that follow ISO-11179 rules you could have a “lab_category” or “lab_type” but never a mixed hybrid. In one of my books, I had something like “lab_category_type_id”
    as a joke; it was so stinking awful that I never dreamed any programmer would really do this! 
    Also OUTER JOINs a rare in a valid schema. A good design will have DRI so you know you have matches. Since a table is a set, their names are plural or collective; but you have only one appointment according to your unseen DDL. And only one “Diagnosis_Report”,
    etc. 
    Now think about “Lab_Category_Types” as a table. Regardless of how this ambiguous mess is resolved, it will be an attribute. An attribute is in a column, not an entity like you are modeling it. If it has a few static values then use a CHECK( x IN (..)) constraint.
    If it is dynamic or large, then use a REFERENCES. Never use a join like this. 
    That silly, magical “delete_status” looks like an assembly language flag. This is what we did with tape files in the 1950's. We would have a bit in the front of records and flip it. Later a program would  move the active records to a new tape. Ask yourself
    why everything in the universe would share a common attribute. Such an attribute would be so generic as to be useless or (your case) it would be meta data and not part of the entity at all. Oh, rows are not records; you got that wrong too. 
    Why do you keep prices in integers? Currency is decimal. Sure wish we had DDL. My guess is that this should look more like this simpler, faster query. 
    SELECT APP.appointment_id,
           LT.lab_type, LR.lab_price,
           DRT.diagnosis_type, DR.diagnosis_price
     FROM Appointments AS APP
          LEFT OUTER JOIN
          (SELECT appointment_id, diagnosis_type,
                  SUM(diagnosis_price) AS diagnosis_price_tot
             FROM Diagnosis_Reports AS DR 
            GROUP BY appointment_id, diagnosis_type)
           AS DR 
          ON APP.appointment_id = DR.appointment_id   
           LEFT OUTER JOIN       
           (SELECT appointment_id, lab_type, SUM(lab_price)lab_price_tot
              FROM Lab_Reports
             GROUP BY appointment_id, lab_type)
           AS LR 
           ON APP.appointment_id = LR.appointment_id 
     WHERE APP.appointment_id = 'MLM-APPOINTMENT-60314748311012015';
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • HT4889 Replacing System hard drive with a new one. How to get everything over to the new boot drive?

    Replacing System hard drive with a new one. How to get everything over to the new boot drive? Should I use Carbon Copy or does apple have a better untility to do this?
    I can't get my current system drive (OSX 10.8.3) to start on the first try. I always have to shut down and restart again to finally see the Apple logo.
    Have used disc utility to repair the disc and permissions several times and that works. The next time I boot up, it works fine and I get the apple logo, but then the second time I boot up, it's back to the blank screen again and it only boots after the second try.  I have tried this repair three different times now always with the same result. Works right the first try (after the repair) then from the second time on it doesn't work. I just get the white screen until I reboot a second time.
    Thinking I should change drives but what's the easist and best way to move everything over to the new drive so it will boot correctly with all my data on it. This is the system drive for a Pro Tools 10HD setup. MacPro 3,1 with 16 gigs ram and OSX10.8.3 on it.
    Thanks for any help!

    If you have a time machine back up of your current drive you can do this
    Shut down your computer, install the new drive. While the computer is off plug in the external hard drive that you have your time machine back up on. Hold Option key while the computer turnes on, let go of the option key once you get a grey screen. Shortly after you'll see  a list of bootable drives, select the one that has your time machine back up on it and boot into that drive.
    From there go into disk utility, format your new drive too, osx extended journaled ( I think, double check that, its been awhile since ive had to do this), hit format
    Exit disk utility and then you can use time machine to copy all your exisit data to the new hhd and then your pretty much done.
    There is also a program called Carbon Cloner that will do esentially the same thing however I've never uesed it.

  • How to get maximal value from the data/class for show in Map legend

    I make WAD report that using Map Web Item.
    I devide to four (4) classes for legend (Generate_Breaks).
    I want to change default value for the class by javascript and for this,
    I need to get maximal value from the class.
    How to get maximal value from the data/class.
    please give me solution for my problem.
    Many Thx
    Eddy Utomo

    use this to get the following End_date
    <?following-sibling::../END_DATE?>
    Try this
    <?for-each:/ROOT/ROW?>
    ==================
    Current StartDate <?START_DATE?>
    Current End Date <?END_DATE?>
    Next Start Date <?following-sibling::ROW/END_DATE?>
    Previous End Date <?preceding-sibling::ROW[1]/END_DATE?>
    ================
    <?end for-each?>
    o/p
    ==================
    Current StartDate 01-01-1980
    Current End Date 01-01-1988
    Next Start Date 01-01-1990
    Previous End Date
    ================
    ==================
    Current StartDate 01-01-1988
    Current End Date 01-01-1990
    Next Start Date 01-01-2005
    Previous End Date 01-01-1988
    ================
    ==================
    Current StartDate 01-01-2000
    Current End Date 01-01-2005
    Next Start Date
    Previous End Date 01

  • I deleted most visited, latest headlines, getting started, yahoo, youtube, apple in mozilla's folder,how to get it back like the first time i installed? thx

    i deleted most visited, latest headlines, getting started, yahoo, youtube, apple in mozilla's folder,how to get it back like the first time i installed? thx

    if you hid the menu bar and the navigation bar simply press the alt button, this will bring back the menu bar and form there you can right click and select which bars you want shown

  • How to get Open Balance for the year and Total Ending Balance?

    For a given account, how to get Open Balance for the year (Cumulative Ending Balance) and Total Ending Balance (Cumulative Ending Balance)?
    Is there any function module available? or should I read from some tables? Please advice.

    Hello Paul,
    You could try calling one of the following BAPIs - see which one meets your requirement. They are documented well so shouldn't be a problem finding out the correct one for your requirements.
    BAPI_GL_GETGLACCBALANCE      
    BAPI_GL_GETGLACCCURRENTBALANCE
    BAPI_GL_ACC_GETBALANCE      
    BAPI_GL_ACC_GETCURRENTBALANCE
    BAPI_GL_ACC_GETPERIODBALANCES
    BAPI_COND_VAL_DECRE_BALANCES
    You might have to put in some of your own logic after the BAPI call to get what you want.
    Hope this helps,
    Cheers,
    Sougata.
    p.s. Also look at FM FAGL_GET_ACCOUNT_BALANCE
    Edited by: Sougata Chatterjee on May 7, 2008 11:47 AM

  • How to get boot camp in the emac

    how to get boot camp in the emac

    Furthermore, eMacs can only emulate the Windows environment, whereas Intel CPU Macs including the iMac you have running 10.6.8 can virtualize Windows.  Emulation is a poor man's solution, because software is used to replace functions that normally take place with hardware.  You can use the iMac to do any data conversion before it gets sent back to the eMac over a network.  See my FAQ* regarding Windows on the Mac:
    http://www.macmaps.com/macosxnative.html#WINTEL

  • Have a new PC desktop with 4 hard drives, new c, d and old c, d, My ipad library is in old c, how to get my itune open the right drive, it keeps on open in new c drive.

    Have a new PC desktop with 4 hard drives, new c, d and old c, d, My ipad library is in old c, how to get my itune open the right drive, it keeps on open in new c drive. It said my computer is not authorized. I want to move all the old c to the new c drive, or get the itune to open my old c drive when I log in.

    might be some help on one of these links.
    Windows - Change iPad default backup location
    http://apple-ipad-tablet-help.blogspot.com/2010/07/change-ipad-default-backup-lo cation.html
    Windows - Changing IPhone and iPad backup location
    http://goodstuff2share.wordpress.com/2011/05/22/changing-iphone-and-ipad-backup- location/
    Sync Your iOS Device with a New Computer Without Losing Data
    http://www.howtogeek.com/104298/sync-your-ios-device-with-a-new-computer-without -losing-data/
    Syncing to a "New" Computer or replacing a "crashed" Hard Drive
    https://discussions.apple.com/docs/DOC-3141
     Cheers, Tom

  • How to get each thread in the threadpool

    Hi,everyone.I'm now learning java.util.concurrent package and I have two questions about the threadpool.
    1) How to get each thread in the threadpool;
    2) How to get each thread's data in the threadpool and dispaly them onto GUI;
    e.g :
    There are 5 threads in the threadpool(ThreadPoolExecutor) and I have 100 tasks(Runnable or Callable),every task scans a directory(every task scans a different directory),how can I display the "real-time" count of the files in the directory which the current 5 threads in the threadpool scan onto the ListView Items in the GUI?

    Willings wrote:
    Hi,everyone.I'm now learning java.util.concurrent package and I have two questions about the threadpool.
    1) How to get each thread in the threadpool;You don't
    2) How to get each thread's data in the threadpool and dispaly them onto GUI;
    e.g : You don't
    There are 5 threads in the threadpool(ThreadPoolExecutor) and I have 100 tasks(Runnable or Callable),every task scans a directory(every task scans a different directory),how can I display the "real-time" count of the files in the directory which the current 5 threads in the threadpool scan onto the ListView Items in the GUI?You should notify your "monitor" when you add something to the pool, and the Runnable/Callable should notify the same "monitor" when it starts to execute, and during its processing. Finally you notify the monitor when the execution has completed.
    Kaj

  • How to get two parameters in the same line of selection screen?

    hello
    i need to get my selection csreen like bellow.
    r1 radiobuttion  -some space --p1 parameter
    i should not get the parameter in the next line of  radiobuttion.
    how to get two parameters in the same line of selection screen?

    hi....
    modify the following code
    it will work
    SELECTION-SCREEN BEGIN OF BLOCK SL1 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 10(15) TEXT-001
                     FOR FIELD P1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS : P1 TYPE   C USER-COMMAND R2 RADIOBUTTON GROUP R2 DEFAULT 'X',
      P2 TYPE SCARR-CARRNAME,
      P3 TYPE CHAR1 RADIOBUTTON GROUP R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK SL1.

  • I excluded iphone from controls in Keynote. How I get it back on the list to use Keynote remote?

    I excluded iphone from controls in Keynote. How I get it back on the list to use Keynote remote?

    Welcome to the Apple Community.
    If you haven't turned find my phone off on the device, it should just reappear next time it is connected to an appropriate network. If you have turned off find my phone, turn it back on.

  • How to fetch table_names along   with the result

    Hi all,
    I want to find strucural differences between two kinds of tables .
    One is original table and another one is archival table .
    All archival table names will have different name from original tables.
    Please tell me how to get table name in the below query..
    ((SELECT column_name, data_type, data_length, data_precision, nullable
        FROM user_tab_columns
       WHERE table_name LIKE '%X271%HIST'
             AND table_name <> 'X271_ELIG_RSPNS_TABLE')
    MINUS
    (SELECT column_name, data_type, data_length, data_precision, nullable
        FROM user_tab_columns
       WHERE table_name LIKE '%X271%'
         AND table_name NOT LIKE '%WS'
         AND table_name NOT LIKE '%_HIST'
         AND table_name <> 'X271_ELIG_RSPNS_TABLE')
    UNION ALL
    ((SELECT column_name, data_type, data_length, data_precision, nullable
         FROM user_tab_columns
        WHERE table_name LIKE '%X271%'
          AND table_name NOT LIKE '%WS'
          AND table_name NOT LIKE '%_HIST'
          AND table_name <> 'X271_ELIG_RSPNS_TABLE')
      MINUS
      (SELECT column_name, data_type, data_length, data_precision, nullable
         FROM user_tab_columns
        WHERE table_name LIKE '%X271%HIST'
          AND table_name <> 'X271_ELIG_RSPNS_TABLE')));Thanks,
    P Prakash
    Edited by: prakash on Sep 5, 2011 5:49 AM

    You'll have to JOIN instead of MINUS:
    SELECT * FROM
      (SELECT table_name, column_name, data_type, data_length, data_precision, nullable WHERE table_name = 'orig') orig
      INNER JOIN
      (SELECT table_name, column_name, data_type, data_length, data_precision, nullable WHERE table_name != 'orig') other
      USING(table_name, column_name)
    WHERE
      orig.data_type != other.data_type OR
      orig.data_length != other.data_length OR
    ...This doesnt show tables whose column names have changed, for that you'll have to use a full outer join:
    SELECT * FROM
      (SELECT table_name, column_name WHERE table_name = 'orig') orig
      INNER JOIN
      (SELECT table_name, column_name WHERE table_name != 'orig') other
      ON(orig.table_name = other.table_name AND orig.column_name = other.column_name)
    WHERE
      orig.column_name IS NULL or
      other.column_name IS NULLYou could maybe combine these.. i know my oracle 9.2 would fall over if I tried so i didnt :)

  • I am using the window xp and firefox 6. I see many videos on youtube. How I get that videos from the catch folder and where is it?

    I am using the window xp and firefox 6.
    I watch the youtube videos online.
    How I get that video from the catch folder and where that catch folder are situated in the window xp.

    ''How can I view or retrieve a video from Firefox's cache''
    To actually view/retrieve the file from the cache and its web address you can use
    the "Cache Viewer" extension 32.8KB
    * https://addons.mozilla.org/firefox/addon/cacheviewer/
    * http://dmcritchie.mvps.org/firefox/firefox.htm#cacheviewer
    For you to be able to view the cached file you would have had to have watched the entire file.
    The latest version of the extension is 0.7b available in all versions you would have to override compatibility by any of these methods
    * checking or pick up one of the xpi versions in the reader comments for Firefox 6.0
    * extensions.checkCompatibility.6.0 set to False
    *: http://kb.mozillazine.org/Extensions.checkCompatibility
    * or with an extension "Add-on Compatibility Reporter" (84.0 KB) seems preferred in this group
    *:https://addons.mozilla.org/en-US/firefox/addon/add-on-compatibility-reporter/
    There are also extensions such as Video downloader 132.8 KB
    * Download YouTube Videos + Flash Video Downloader / Download-Helper
    *:https://addons.mozilla.org/firefox/addon/download-youtube-videos/
    <br><small>Please mark "Solved" one answer that will best help others with a similar problem after you've tried several things.</small>

  • Sum of the Results

    hello...we have some problem in summing out the results for the /BA1/K62EAD here based on the  /BA1/C62UEXPOS. When we execute the program, the results always showing a few lines of the same  /BA1/C62UEXPOS as below:
      /BA1/C62UEXPOS /BA1/K62EAD
    a  20
    a  30
    a  40
    b  30
    and the expected results should be a = 90 which is a sum but we got the results as below which break down to several records. what can we do on these? we have the code as below:
    SELECT /BA1/C20BPART
           /BA1/C62UEXPOS
           /BA1/K62EAD
           /BIC/OBJ_CURR
           FROM /1BA/HM_8QZO_400 INTO wa_rdldata
            FOR ALL ENTRIES IN i_resmort
                WHERE /BA1/CR0GROUP = group_id AND
                      /BA1/C62UEXPOS NE i_resmort-t_mort_ftid_dum.
       COLLECT wa_rdldata INTO i_rdldata.
       SORT i_rdldata.
    ENDSELECT.

    Hi,
    try the code and revert back for any prob
    SELECT /BA1/C20BPART
           /BA1/C62UEXPOS
           /BA1/K62EAD
           /BIC/OBJ_CURR
           FROM /1BA/HM_8QZO_400
         INTO table i_rdldata
            FOR ALL ENTRIES IN i_resmort
                WHERE /BA1/CR0GROUP = group_id AND
                      /BA1/C62UEXPOS NE i_resmort-t_mort_ftid_dum.
    loop at i_rdldata INTO wa_rdldata.
    COLLECT wa_rdldata INTO i_rdldata.
    endloop.
    Regards,
    Anirban

Maybe you are looking for

  • Mirrored Raid as boot disk?

    I have a flat panel iMac (PPC) that I would like to have a bit more reliable. Due to the number of files I have on this machine, it is currently configured to boot from an external Firewire drive. Recently, I have added a second external firewire dri

  • How to Reset the EIM \ CIM System "sa" Password Procedure

    All. I have posted a document, "How to Reset the EIM \ CIM System "sa" Password Procedure" on this CSC site to assist you w\ the EIM "sa"user password reset procedure. I am also posting the procedure and word document attachment here. Let me know how

  • Iphone stuck on rebooting screen and wil not let me restore

    my iphone is stuck on reboot screen and will not let me restore

  • Custom invoice

    stock Transfer orders once we create PO and delivery for a plant abroad we file custom invoices to custom authorities. However if price of material or tranfer price margin changes in between, the intercompany invoice gets a different value. It causes

  • ALV SAVE BUTTON IN CHANGE LAYOUT

    HALLOW  I USE A ALV AND I WONT TO HAVE A BUTTON OF SAVE IN  TOOL BAR IN THE <b>butten cange layout</b> HOW CAN I DO THAT?THANKES THIS IS MY ALV CODE dATA: ok_code LIKE sy-ucomm,       g_container TYPE scrfname VALUE 'BCALV_GRID_DEMO_0100_CONT1',