Problems with lines due double date/time in the query

Hello

I'm trying to draw a list of the counties of the test sample. I want only 1 rank by the test result so that I can build a report in Cognos showing the rate of an outcome determined as a percentage of the total causes a range of dates.

My problem is that I get duplicate for the same result rows: in the example below, I have 2 to 5 lines for each result instead of only 1 for each result. I have this reduced up to caused by the date - the date is the same, but the times are different, if several lines are drawn. I tried to use tronque(), among other things, but although the output now shows the same date without the time part, duplicate rows are always drawn.

Any help would be appreciated!

This is the code for the query:
SELECT DISTINCT
    io.lab_id AS "LAB ID",
    l.name AS "LAB NAME",
    mtr.marketingtest_id AS "TEST ID",
    mtl.name AS "TEST NAME",
    mtr.marketingresult AS "MARKETING RESULT",
    COUNT(DISTINCT mtr.sample_id) AS "NO OF SAMPLES",
    TRUNC(os.statusdate) AS "STATUS DATE",
    os.orderstatuscodes_id AS "ORDER STATUS",
    io.redoorderid AS "REDOORDERID",
    mtl.locale_id AS "LOCALE"
FROM igen_sample s
INNER JOIN igen_igenityorder io ON s.igenityorder_id = io.igenityorder_id
INNER JOIN igen_orderstatus os ON io.igenityorder_id = os.igenityorder_id
INNER JOIN igen_marketingtestresult mtr ON s.sample_id = mtr.sample_id
INNER JOIN igen_lab l ON io.lab_id = l.lab_id
INNER JOIN igen_marketingtestlocale mtl ON mtr.marketingtest_id = mtl.marketingtest_id

WHERE mtl.locale_id = 1
AND os.orderstatuscodes_id IN (8, 9)
AND mtr.marketingtest_id = 84
AND os.statusdate BETWEEN '24-OCT-2011' AND '31-OCT-2011'

GROUP BY mtr.marketingtest_id, mtl.name, mtr.marketingresult, os.statusdate, os.orderstatuscodes_id, io.lab_id, l.name, io.redoorderid, mtl.locale_id
ORDER BY mtl.name

Hello

893078 wrote:
Hello

I'm trying to draw a list of the counties of the test sample. I want only 1 rank by the test result so that I can build a report in Cognos showing the rate of an outcome determined as a percentage of the total causes a range of dates.

My problem is that I get duplicate for the same result rows: in the example below, I have 2 to 5 lines for each result instead of only 1 for each result. I have this reduced up to caused by the date - the date is the same, but the times are different, if several lines are drawn. I tried to use tronque() among others...

TRUNC looks like what you want. If you want a single line per calendar day, or need to GROUP BY TRUNC (os.statusdate).

AND        os.statusdate  >= TO_DATE ( '24-OCT-2011'
                            , 'DD-MON-YYYY'
                        )
AND       os.statusdate  <  TO_DATE ( '31-OCT-2011'
                             , 'DD-MON-YYYY'
                        ) + 1
GROUP BY  mtr.marketingtest_id
,            mtl.name
,        mtr.marketingresult
,        TRUNC (os.statusdate)               --     <==  CHANGED
,        os.orderstatuscodes_id
,        io.lab_id
,        l.name
,        io.redoorderid
,        mtl.locale_id
ORDER BY  mtl.name

If os.statusdate is a DATE, don't try to compare it to a VARCHAR2, as 24 October 2011 "." Compare DATEs to other DATEs.

Furthermore, GROUP BY product automatically separate results. If all GROUP expressions in the SELECT clause, there is not need to say SELECT DISTINCT .

Published by: Frank Kulash, November 23, 2011 09:34

Tags: Database

Similar Questions

  • Problem with run invoke vmscript several times on the same VM

    The following is a test command I am running

    $PCCreds = Get-Credential
    $VM = Get-VM -Name "Test-VM"
    while ($VM -ne $null) 
         {
         $VM | Invoke-VMScript -GuestCredential $PCCreds -ScriptType Bat -ScriptText 'whoami' 
         Start-Sleep -Seconds 10
         }
    

    While in this infinite loop, I receive a mixture of success and failures

    ScriptOutput
    ----------------------------------------------------------------------------------------------------------------------
    Test-VM\user
    |  
    ----------------------------------------------------------------------------------------------------------------------
    Invoke-VMScript : 7/9/2012 11:22:12 AM    Invoke-VMScript        While performing operation 'Connect to host service '
    https://vcenter.local/sdk' at port 902' the following error occured: 'Unknown error'    
    At line:15 char:45
    + while ($VM -ne $null) {$VM | Invoke-VMScript <<<<  -GuestCredential $PCCreds -ScriptType Bat -ScriptText 'whoami'
    Start-Sleep -Seconds 60}
        + CategoryInfo          : OperationStopped: (:) [Invoke-VMScript], VimException
        + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_VixWaitForJob_VixError,VMware.VimAutomation.ViCore.Cmdlets. 
       Commands.InvokeVmScript
     
    ScriptOutput
    ----------------------------------------------------------------------------------------------------------------------
    Test-VM\user
    |  
    ----------------------------------------------------------------------------------------------------------------------
    

    With an array of objects of virtual machine using this same code seems to work without problems. These virtual machines are distributed over several hosts.

    My guess is that this has something to do with sequential to the same host, reaching a connection limit max, as well as the connection is not completed after a successful execution of the cmdlet. Has anyone seen this problem before?

    Against what version of vSphere are you running that?

    And are you using PowerCLI 5.0.1?

  • Problems with line spacing - not able to adapt

    Having some problems with line spacing - I work in a file that I've not been created.  The phenomenon that occurs is as follows: I have a block of text, when I increase or decrease the foreground one point at a time, nothing happens. As I continue to increase, the line of text will suddenly blow up about a quarter of an inch.

    For example, I 8.5pt type whose main value to auto (10.2) - I hit increases by increments of 1 point, the line does not, only when I get to 13pt we must answer and bumps up to about 1/4 in. I continue to increase by increments of 1 point 13, and line does not respond until I reach 25pt, how the line of bumps down on another 1/4 of an inch.

    This could be the cause?

    It's not downtown... The text is printed to line up on the starting grid.

  • Hang the problem with applications. Fixed by going to the taskbar or by minimizing and maximizing return

    Hello world

    I have a weird problem with Adobe applications. Mamy times especially when doing drag or double click, applications get stuck. And if I move my mouse away from the application to the taskbar, it kicks back. Or sometimes I have to minimize and maximize return.

    It happens when I use my Tablet intuos with pen. So if it gets stuck, I noticed as soon as I change the feather to the touch, it begins to function normally. Otherwise, I have to hover on the taskbar or minimize and optimize the thing.

    I tried to re install creative cloud and applications, I tried to delete / re install drivers Wacom.

    not sure if it's a cc or a Wacom or Windows 10 problem. ID appreciate any help. It drives me crazy that am not not able to work.

    I thank nk so

    Hi Irfani7193203,

    Please let us know what Adobe application you talk too much.

    Until then, you can consult the links below:

    Resolve Windows system errors, freezes | Adobe software

    Applications Adobe Creative Cloud close immediately after the launch

    Waiting for your response.

  • I had a problem with slow, so I used "reset". The popup ran forever so I stopped it. Now I can not remove or add the program.

    I had a problem with slow, so I used "reset". The popup ran forever so I stopped it. Now I can not use, remove or add the program. How should I proceed?

    TIA,
    BWSwede

    Try to create a new profile.

    See "create a profile":

    If the new profile works then you can transfer files from a profile in the new profile, but make sure not to copy corrupted files.

    What problems do you have that you want to reset Firefox?

    Firefox creates a new folder of old data of Firefox on the desktop?

    If reset you Firefox and a new profile is created and some of your data (bookmarks, passwords, cookies, form data) is automatically imported and your current profile will be moved on the desktop (old data of Firefox).

  • Display Date/time of the Client system

    Hello

    The requirement is to display the report run date/time in the result. (Report is developed using Excel template)

    Following syntax would give me time of the server where BI Publisher is installed.

    <? xdoxslt:SYSDATE('DD-Mon-YYYY_HH24:MI:SS')? >

    But, users would like to see their client system local date/time. There are several users running the report to several time zones.

    Any help on this is much appreciated.

    Thank you

    Mani

    before =)

    What is values of $_XDOLOCALE and $_XDOTIMEZONE, then you run the report with or without the user preferences?

    can you please check and share the result

    Add these variables to test the output of the report and please post on its values

    so, if the values of the variables are picked from the user's preferences, you can simply use

    If the values are the values of server beep then, as of ideas,

    -some additional report parameters (can be hidden) dynamic picking local / zone by other additional tables as user/local/zone schedule

    (intermediate table to store the preferences of users - custom extension)

    so, you for certain user values in this table, then you can set their default values for the parameters and pass to the generation of reports

    If missed - use beep server settings

    - or post SR to take over the team, already can be a useful way is existed

  • AI CS5 keyboard shortcuts do not work. I restarted and have no other problem with my MacBook Pro. What is the problem?

    AI CS5 keyboard shortcuts do not work. I restarted and have no other problem with my MacBook Pro. What is the problem?

    Bill,

    The following is a general list of things, try when the question is not in a specific file, and when it is not caused by problems with opening a file from external media. You tried/made some of them already; 1 and 2) are easier for temporary strangenesses and 3) and 4) specifically preferences might be corrupt); ((5) is a list in itself and 6) is the last resort.

    If possible / there is, you must record a current work first, of course.

    (1) close Illy and open again.

    (2) restart the computer (you can make up at least 5 times);

    (3) close Illy and press Ctrl + Alt + Shift / Cmd + Option + shift during startup (easy, but irreversible);

    4) move the folder (follow the link with this name) with closed Illy (more tedious but also more thorough and reversible), for CS3 - CC you can find the file here:

    https://helpx.Adobe.com/Illustrator/KB/preference-file-location-Illustrator.html

    5 look through and try the relevant among the other options (click on the link with that name, item 7) is a list of the usual suspects among other applications which can disturb and confuse Illy, point 15) applies to the maybe CS5, CS6 and CC);

    Even worse, you can:

    (6) (check the box to delete the preferences), run the cleanup tool (if you have CS3/CS4/CS5/CS6/CC) to uninstall and reinstall.

    http://www.Adobe.com/support/contact/cscleanertool.html

  • Have a problem with Lightroom 5.4.  Given that the program crashed yesterday, will not start, it comes up with the message "Lightroom has encountered an error when reading the preview cache and need to quit."  "Lightroom will attempt to fix this ti net pr

    Have a problem with Lightroom 5.4.  Given that the program crashed yesterday, will not start, it comes up with the message "Lightroom has encountered an error when reading the preview cache and need to quit."  "Lightroom will attempt to solve this problem, the next time he throws."  Except that it isn't, I get the same message and the program closes.  Anyone know what I can do to fix it?  Can not backup, can't do anything.

    There are dozens of discussions in this forum that describe the fix

  • How to display date / time in the browser console?

    How to display date / time in the browser console?

    You can set through the Options (gear icon) page in the Web Console (Firefox/tools > Web Developer).
    This applies to the browser console and the Web console.

  • How to write the Date/time of the PDM file property

    On the page root of the PDM file, there is a predefined, property called ' Date/Time' in the first row.

    I would use it to save the timestamp when the tdms file is created. But in the help file.

    I find that the following property constant. So, how can I write to the field of property ' Date/time '?

    Property Constant Data type
    Name TDMS_FILE_NAME String (char *)
    Description TDMS_FILE_DESCRIPTION String (char *)
    Title TDMS_FILE_TITLE String (char *)
    Author TDMS_FILE_AUTHOR String (char *)

    Thanks for any idea or suggestion.

    You are not sure if it's exactly what you want, but have you tried that?

    CVIAbsoluteTime            CVItime, *t = NULL;
    TDMSFileHandle          deH = 0;
    
    // Create TDMS file and set some properties
    errChk (TDMS_CreateFileEx (file, TDMS_Streaming2_0, TDMS_ByteOrderNative, 0,"example.tdm", "someText", "title", "author", &deH));
    
    // ...
    
    GetCurrentCVIAbsoluteTime (&CVItime);
    errChk (TDMS_SetFileProperty (deH, "Date/Time", TDMS_Timestamp, CVItime));
    
    // ...
    
    // Save and close fileerrChk (TDMS_SaveFile (deH));TDMS_CloseFile (deH);
    
  • Extracted from LAVA - crush keeps old date/time of the png file

    I don't know if this is a bug, or to behave like that.

    Scenario: create an extract using the tool of LAVA. I just use the same name (and path) of an existing png file that was created by the same LAVA tool a few days before also (so I replaced the original file). I opened the case, and to quickly find the newly created excerpt, I ordered the files as a descendant by time and date. To my surprise I couldn't find the code snippet in the upper part. The reason was that the new file kept the date/time from the original one.

    This is a really minor thing, but it made me curious. Under windows, when I rename a file, it retains the original timestamp. However when I crush him, it updates.

    LabVIEW 2015 (32-bit),

    Code Capture Tool v3.2.1 - 46 lava

    As I said, look at the code of the COMMON customs tariff. The only thing I can think of that would make it interesting is the code snippet, which is a flow within the PNG file, something that the VI of shipment is not compatible. I don't know more how it's done exactly - it might be created under the PNG in memory and then writes to the file directly or can be injected into the file after shipping VI saves it.

    Either way, I just did a test fast in Notepad and if I do record under and tell him to replace an existing file, the date of the creation of this file does not seem to change so this seems to be normal behavior for Windows. I don't know if the Windows API file deletes the file and creates a new or simply modifies the existing file when you perform this operation.

  • Problem "there could be a problem with one or more network adapter on the computer?

    Hi, I just changed my modem, I can't connect to the internet. I can connect to wireless network but not to the internet. When I diagnose, he said, "there could be a problem with one or more network adapter on the computer. I searched the internet but I can't find anything. When I diagnose, I have also seen something on the 'hot spots', but I can't remember it clearly? Any help please?

    Also, when I go to Device Manager network adapters, each of them has WARNING signs except two of them.

    Hello:

    If your laptop is an Atheros AR5007 wireless card, see if installing this driver solves the problem, you have to be able to connect to wireless but no internet network.

    http://h10025.www1.HP.com/ewfrf/wc/softwareDownloadIndex?softwareitem=ob-108905-1&cc=us&DLC=en&LC=en&JumpID=reg_r1002_usen_c-001_title_r0004

  • I have a problem with my laptop does not connect to the internet. It connects to our wireless very well, but it doesn't have an internet connection.

    I have a problem with my laptop does not connect to the internet. It connects to our wireless very well, but it doesn't have an internet connection. It connects to other networks wifi very well with Internet access, is that the wireless in my house what it connects to. When I diagnose the problem, it says "Cannot communicate with DNS server (208.67.222.222)", and then under that it says: "languished network diagnostics remote hosts, but had not received a response." It connects to the Internet through an ethernet cable, but it is rather annoying pulling the cable autour. I currently have Windows Vista Home Premium. Thank you!

    original title: Internet connectivity problem

    Hello

    Now, you may need to contact the support of Panda Internet Security centre to change the settings so that wireless is enabled through it.

    Support link: http://www.pandasecurity.com/homeusers/support/

  • I have a problem with corruption.  How can I change the timeline on an existing project.  Each image is moved about 2.5 min.;  My preferences are for 180 frames.  It does not seem to consider one after the fact.  Is it possible to copy the entire thing on

    I am new to use the forums.  How to start a discussion?  The ICO next which is grayed out.

    I have a problem with corruption.  How can I change the timeline on an existing project.  Each image is moved about 2.5 min.;  My preferences are for 180 frames.  It does not seem to consider one after the fact.  Is it possible to copy the whole thing and put it in a new, m not corrupted project?

    Hello and welcome.

    I feel for you after reading your story, however, it that are supposed to do? It is a forum for Dreamweaver and to my knowledge, Dreamweaver has no functionality called the chronology.

    Could you please explain the problem so that we can understand?

  • Inserting data by using the query

    Hello

    In a book, I read the Sub statement:

    Inserting data by using the query (DML)

    If the user wants to transfer data from a table to another table in the insert statement are used independently of data that can be processed or not processed form.

    Can someone clarify what is the significance of this (processed or unprocessed form).


    Thank you.

    Why don't you ask the author of the book.

    How can we know what the author means when you take a quote out of context and don't provide any reference so that we can see exactly what is shown to you.

    I can only imagine that they are referring to data that are queried directly, "like what", another table, or who was interrogated and manipulated before be inserted.

Maybe you are looking for