Setting Criteria on a COUNT variable

Hello:
I have a query where I am counting the number of visits per patient. I need to extract only those patients who have more than 2 visits. When I attempt to set my condition based on my COUNT function, I'm receiving the following error message:
ORA-00904:VISITS invalid identifier
I tried placing my condition in a number of places and I'm still receiving the same error message. I made three different attempts to with the condition statement.
The query that I currently have without the visits condition is the following (I commented out the VISITS criteria):
SELECT A.DWKEY_PATIENT, COUNT(A.TRAIT_DATE) VISITS
FROM HELEN.DOCUMENT_TRAITS A, HELEN.PATIENT_DIM B
WHERE A.ID=B.ID
      AND A.DWKEY_PATIENT=B.DWKEY_PATIENT
      AND B.DWKEY_ORG = 45
      AND TRUNC(MONTHS_BETWEEN(SYSDATE,B.DATE_OF_BIRTH)/12) >=18
      AND A.TRAIT_DATE >= '01-SEP-06'
      AND (A.TRAIT_VALUE <= '35' OR A.TRAIT_VALUE = 'Y')
      AND  A.DWKEY_TRAITTYPE IN (36883,36884,36885)
*--and visits > 1 (attempt #1)* 
AND NOT EXISTS (SELECT 1
                FROM HELEN.DOCUMENT_TRAITS B
                WHERE B.DWKEY_PATIENT = A.DWKEY_PATIENT
                AND B.DWKEY_TRAITTYPE = 36391)
*--and visits > 1 (attempt #2)*
GROUP BY A.DWKEY_PATIENT
*--HAVING VISITS > 1 (attempt #3)*The result this query produces looks like this:
ID   DWKEY_PATIENT    VISITS
1    45454545          1
2    23232323          1
*3    12121212          2*  ((this is the only record that should appear after adding VISITS > 1)) Once I include the condition of VISITS > 1 the result of the query should only display record #3: dwkey_patient 12121212 with 2 visits. Records 1 and 2 should disappear.
I cannot seem to figure out where to place my VISITS > 1 in my query to produce the desired result.
My second issue with the query is to include the following fields from the tables:
dwkey_patient from patient_dim table,
date_of_birth from patient_dim table,
age calculation,
dwkey_traittype from document_traits table,
trait_date from document_traits table,
trait_value from document_traits table
When I try to include these columns in my SELECT statement, I receive a message stating: not a group by expression.
This is where I'm trying to place the additional columns:
SELECT A.DWKEY_PATIENT, COUNT(A.TRAIT_DATE) VISITS, b.date_of_birthCan someone help me out?
Thank you.
Edited by: hbradshaw310 on Nov 9, 2008 3:21 PM

And yes, your attempt #3 is the right one assuming you just need just patient. And since you need non-aggregated data, use:
SELECT  DWKEY_PATIENT,
        VISITS,
        date_of_birth
  FROM  (
         SELECT  A.DWKEY_PATIENT,
                 COUNT(A.TRAIT_DATE) OVER(PARTITION BY A.DWKEY_PATIENT) VISITS,
                 b.date_of_birth
           FROM  HELEN.DOCUMENT_TRAITS A,
                 HELEN.PATIENT_DIM B
           WHERE A.ID=B.ID
             AND A.DWKEY_PATIENT=B.DWKEY_PATIENT
             AND B.DWKEY_ORG = 45
             AND TRUNC(MONTHS_BETWEEN(SYSDATE,B.DATE_OF_BIRTH)/12) >=18
             AND A.TRAIT_DATE >= '01-SEP-06'
             AND (A.TRAIT_VALUE <= '35' OR A.TRAIT_VALUE = 'Y')
             AND  A.DWKEY_TRAITTYPE IN (36883,36884,36885)
  WHERE VISITS > 1
/SY.

Similar Messages

  • Can't set or retreive a $_GET variable

    I have a problem setting up and passing a variable in a search screen with paging..
    I set up the variable like so
    $townstr = sprintf("&townstr='%s'", $searchTown);              
    This variable is then added to the URL string when I click on the 'Next page';
    <a href="<?php printf("%s?pageNum_Get1=%d%s%s%s", $currentPage1, min($totalPages_Get1, $pageNum_Get1 + 1), $queryString_Get1,$tabstr,$townstr); ?>"> Next</a>   
    The problem in, when the page is loaded again to show the next screen, the $_GET variable $_GET['townstr'] is always empty,
    Any Ideas why it is not being set up.
    I displayed it straight after the href code and can't access it, although it's definitely there, as I can see it as part of the URL when I move over the link when running the program.

    That's a little confusing to me... once the recordset has been returned, the paging links should only be updating the display of the results that have already been returned.
    When I've done things like this, an events list for an organization for example, I would set the query like
    SELECT date, event, start_time
    FROM events
    WHERE some_field = some_variable
    Then, I create a repeating table showing, say, only 5 records at a time... then I just go to the "recordset paging" button and insert whatever "Next/Last/First/Previous" links that I want... as I page through the pages, it doesn't "forget" the search criteria, because that has already been set by the query.
    I realize I'm not answering your question, it just seems like what you're talking about shouldn't be happening. And the fact that it is seems to indicate something else may be going on.
    By the way, my "NEXT" button (on the first page of results) URL looks like this (this was set automatically by DW):
    mypage.php?pageNum_Recordset1=1&totalRows_Recordset1=24

  • Setting the Vissible Row count Dynamicaly

    Hi,
        I need to set the Vissible row count dynamically in Webdynpro Java, depending upon the number of rows in the internal table.

    Hi Delphi,
    This is Webdynpro ABAP Forum, Try to post in Webdynpro Java. I dont know WD Java.
    Create one attribute of type i  ex : COUNT TYPE I, and bind to visible row count property of table.
    In code Describe table and get total no of records to one variable.
    Finally use Set_attribute - Pass COUNT Value. Now Based on Count Value you get no of table rows.
    Hope it Helps.
    Cheers,
    Kris.

  • Updating dynamic counter variable

    I have a form that populates form fields with database
    records to edit.
    This works fine.
    When i attempt to loop through the records to update i get an
    error.
    Obviously it has to do with my syntax of my variables (
    LowerQty='form.LowerQty#count#',
    UpperQty='form.UpperQty#count#',
    Price=form.Price#count# WHERE id='form.id#count'# )
    When i attempt to update the database. It is attempting to
    enter the string
    value "lowerQty1" rather that it actual intger value=1. What
    is the correct
    syntax to write these variables in cold fusion? Thanks in
    advance.
    <!----form------>
    <cfset count=0>
    <form name="form2"
    action="pricecode_adjust.cfm?stage=update"
    method="post">
    <table width="600" border="1">
    <cfoutput query="PriceCodes" startrow="1"
    maxrows="#pricecodes.recordcount#">
    <cfset count=#count#+1>
    <tr>
    <td width="100px">Price Code:
    #pricecode# <input name="id#count#" type="text"
    value="#pricecodes.id[count]#" /></td>
    <td width="100px">Lower Qty#count#:
    <input type="text" name="LowerQty#count#" size="6"
    maxlength="6"
    value="#pricecodes.lowerqty[count]#" /> </td>
    <td width="100px">Upper Qty#count#:
    <input type="text" name="UpperQty#count#" size="6"
    maxlength="6"
    value="#pricecodes.upperqty[count]#" /></td>
    <td width="100px">Price#count#: <input
    type="text" name="Price#count#" size="6" maxlength="6"
    value="#pricecodes.price[count]#" /></td>
    </tr>
    </table><input name="Update" type="submit"
    id="Update"
    value="Update Price Code" />
    <!-----store the loop count in hiiden field---->
    <input name="recordcount" type="hidden"
    value="#pricecodes.recordcount#" />
    </cfoutput>
    </form>
    <!----update------>
    <cfif stage eq 'update'>
    <!---Loop through pricecodes to be updated--------->
    <cfloop index="Count" from="1"
    to="#form.recordcount#">
    <cfquery name="query" datasource="#client.dsn#"
    username="#client.username#" password="#client.password#">
    UPDATE cost
    SET
    LowerQty='form.LowerQty#count#',
    UpperQty='form.UpperQty#count#',
    Price=form.Price#count#
    WHERE
    id='form.id#count'#
    </cfquery>
    </cfloop>
    </cfif>

    if you have tried looking for an answer first, you would have
    found it
    in this very forum only 2 threads before yours!
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=13 28096&enterthread=y
    and another one only 4 before yours!!!
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=13 28004&enterthread=y
    and there was another one earlier today on exactly the same
    subject!
    and don't forget to RTFM:
    http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_3_CFML_Ref_1.html
    hth
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Setting static IP with computer variables with ConfigMgr 2012 R2 + MDT 2013?

    Hi!
    So im trying to set static IP with computer variables in ConfigMgr 2012 R2 with MDT integration. Does not seem to work as expected, after installation it has DHCP enabled.
    This is my config:
    ZTINicConfig.log
    <![LOG[Property ForceCapture is now = ]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[Microsoft Deployment Toolkit version: 6.2.5019.0]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[The task sequencer log is located at X:\WINDOWS\TEMP\SMSTSLog\SMSTS.LOG. For task sequence failures, please consult this log.]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[ZTINicConfig Script Entered.]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[ PHASE = ]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[ Deployment Method = SCCM]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[ Deployment Type = NEWCOMPUTER]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[Capture Network Settings from local machine and write to Environment.]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[Query networking adapters...]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[Networking Adapters found! Count = 1]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[Property OSDAdapterCount is now = 0]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    <![LOG[ZTINicConfig processing completed successfully.]LOG]!><time="14:18:29.000+000" date="03-19-2015" component="ZTINicConfig" context="" type="1" thread="" file="ZTINicConfig">
    And I can't find any of the variables specified in ZTIGather.log. Do they only work with pure MDT or in CS.ini ?
    Any Ideas ?
    Thanks!

    Many methods to achieve the same. I've done something similar once with a small PowerShell script like this:
    http://www.petervanderwoude.nl/post/setting-a-static-ip-address-during-a-deployment-via-powershell-and-configmgr-2012/
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • Assigning a specific value to the sapscript counter variable

    Hi all,
    I am trying to use the sapscript counter variable in my sapscript but encounter the following warning.
    My code looks like the following:
    /: DEFINE &SAPSCRIPT-COUNTER_0& = 0
    The new counter value is &SAPSCRIPT-COUNTER_0(+)&
    The warning i get when i do the syntax check is:
    Ambiguous symbol &SAPSCRIPT-COUNTER_0&
    What is wrong with my syntax?
    Appreciate any help i can get.

    Hi,
         If i am not wrong you are trying to reinitializing that standard variable. if that is the case one thing, in script we cannot assign values to variable other than at initializing time but here you don't have chance to initialize that variable because that is standard one. More over modifications to standard variable will give some warnings.
    So try to use other than standard one as per your requirement.
    Hope this will help you.
    Regards,
    Aswini.

  • How to Set and Use a global variable within a session?

    Dear All,
    I'm new to jsp, and would like to ask how to set and use a global variable within a session?
    Thanks in advance.
    Regards,
    Cecil

    With session.setAttribute("name",object) you can store a Attribute in the session object.
    with session.getAttribute("name") you can get it.
    That's it.
    Regards,
    Geri

  • Set a value for a variable of type exit

    Hello,
    I am filling some variables with multiple values in user exit.
    Now, i would like to place some of these characteritics in Header area. It's of course impossible because there is multiple values but ...
    I will put dropdown box in the web application for these chars. The problem is that by default, any value is assigned to the dropdwom ( any variable value is set).
    Do you know how i can set a value for theses variable after filling all values by the user exit. SO that only one value is selected for the header and all others values available in the dropdown ?
    Regards,
    Jarod

    Hi,
    Off late, this seems to be a usual requirement.
    Just create a Z program to call the FM API_SEMBPS_VARIABLE_SET and then call the FM API_SEMBPS_POST.
    you should be preparing the content/set value to pass to the FMs. check the whereused list to see how this FMs can be used/called.
    finally, run this program for your variable, after the loading/filling the exit variable. Please note that to set 'exit' variables, the sourcing variable's content need to be read/set first before setting the exit varible.
    HTH,
    Regards,
    Nataraj.

  • How to set List of String as variable value in BPEL

    I am using java embedding to invoke a method which returns a list of strings. I need to set these values in a variable in BPEL to be used later. I am getting following error while setting the value.
    <May 2, 2012 5:18:20 PM IST> <Error> <oracle.soa.bpel.engine.dispatch> <BEA-000000> <failed to handle message
    com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}mismatchedAssignmentFailure}
    messageType: {{http://schemas.oracle.com/bpel/extension}RuntimeFaultMessage}
    parts: {{
    summary=<summary>Mismatch Assign.
    cannot set a nonelement value to an element-based variable.
    An attempt to assign a nonelement value to an element-based variable failed.
    Verify the BPEL source for invalid assign activities.
    </summary>}
    Following is the java code
    List<String> providers = Registory.getProviders("1");
    setVariableData("providerList", providers);
    I have defined a xml element in the wsdl defintion:
    <xsd:element name="providerList">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="providerId" type="xs:string" maxOccurs="unbounded" minOccurs="0" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    providerList variable is of type "providerList".
    What else do I need to do to convert the List to the xml elements ?

    Well I believe this is not officially mentioned anywhere, but this is the limitations for the java embedding activity. You can assign value to a single variable or to the single part element of variable only. I suggest you go with a java web service. you can check more details on java embedding activity @ http://docs.oracle.com/cd/E21764_01/integration.1111/e10224/bp_java.htm
    void setVariableData(String name, Object value)
    void setVariableData(String name, String part, Object value)
    void setVariableData(String name, String part, String query, Object value)

  • Need to set the Vissible row count Dynamically

    Hi,
       I have requirement where i am supposed to set the Vissible row count for a table dynmaically, depending upon the number of rows in a table.

    Or use a calculated attribute.
    Create an attribute in the context called calcVisibleRowCount of type integer and make it read only and calculated. Then bind that attribute to the visibleRowCount attribute of your table.
    The method for the attribute looks something like this:
    (this displays 10 rows per page if more than 10 records in the node, otherwise it displays the same number of rows in the table as in the context)
      public int getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement element)
        //@@begin getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement)
              if (wdContext.nodeXXXX().size() > 10) {
                   return 10;
              } else {
                   return wdContext.nodeXXXX().size();
        //@@end
    Note that this attribute is not created in the node that you want to count number of elements in.
    Edited by: Richard Linnander on Apr 1, 2011 3:41 PM

  • How to set report output to session variable

    Hi,
    Is there any way to set report output to session variable . If my report returns 1 row and 1 column.
    I have a dashboard prompt where i am selecting Name , but i want to find out the ID of that name .
    that ID i want to pass to a column Fx , to achieve this i created a intermediate report and i got the ID. Now my problem is how do i set this ID in session variable .
    Please help if anyone knows...

    Did you read this:
    how to set session / presentation variable in repository variable
    Dashboard prompt on Month Name but report filter on month ID:
    Re: Dashboard prompt on Month Name but report filter on month ID needed
    If you have dashboard prompt (name) then you may have only one report that is filtered by name but show id or not show id but use id in the function. Or two reports like in the solution in the second link above and the second report has id in the function and filter by id from the first report. You don't need to set this ID in session variable for this example.
    Please close your previous threads if they are answered.
    Regards
    Goran
    http://108obiee.blogspot.com

  • BPM Counter Variable

    FILE1---> XI -->  IDOC
    I have a BPM to receive the File. Do the Transformation and then send to R/3 as requested. This scenario is working fine for me. The only problem I have is, I need to send a mail at the end of the process, saying that how many IDOCs were sent to R/3.
    I have introduced a Counter Variable(SimpleType,Integer) and counting each time an IDOC is created.
    But when I add a new step to send the Counter Variable, I dont even see that variable in the Message variable of the SEnd Step!!!
    What am I doing wrong?

    Hi Mohan,
    you cannot send variables - only messages
    (there's no way to map variable to a message in BPM)
    how can you do your scenario?
    you can do 1:2 mapping
    you can map your file to 2 kinds of messages:
    - idoc
    - message with one field(conuter)
    then map file to those 2 messages and counter has to contain the number of idocs
    then you'll be able to use it in send step:)
    BTW
    if you're not using combined IDOC have a look at my weblog:
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a>

  • Global Counter Variable - Graphical Mapping

    Hi there.
    Can anybody help with implementing a global counter variable in the graphical mapping please.
    I am trying to populate the "SEGMENT" field of an IDoc with the correct sequence, i.e. add 1 for each new segment. The IDoc has several segments, most of which are embedded. I have tried using the "<b>counter</b>" function but this seems to reset back to one for each instance of it being called.
    I would appreciate any pointers.
    Thank you.
    Mick.

    Hi see this for implementation
    <b>defining Global Variables</b>
    ArrayList arrVI;
    int counter =0;
    <b>Initialization Section</b>
    arrVI= new  ArrayList();
    <b>assignment</b>
    arrVI.add(sVI[iLoopCounter]);
    counter++;
    <b>
    fetch Values</b>
    for (int i =0;i<counter;i++)
    result.addValue(arrVI.get(i)+"");
    Mudit

  • Need to keep track of URL and a count variable

    Can anyone suggest the best way to keep track of a URL and a count variable associated with each URL. I have started using 2 List objects. When I add a URL I also add a 1 in the count List Object. I am using List Objects because I must be able to sort them and search through them.
    Can anyone verify that I am going about this the correct way?
    Thanks

    I would probably use a TreeMap that referenced the counter.

  • Resetting a counter variable

    I am trying to use counter variable "count". The default for "count" is 0 when the program is opened up. I initialize ssd and sumclick to be 0. However once it goes through the formula node, the value for "count" changes to 1 and then the decision loop within the formula node that checks if "count>0" is used.
    My problem is, if I stop the program and then rerun the program without closing and reopenign the program, the value for count continues to be 1, and so my intialization for ssd and sumclick dont happen. Whenever I hit the run button I want count to be 0. I dont want count to remember the 1 from the previous run. How can I do this?
    The VI is below.

    Hi Charles,
    Thanks for answering my question. The pciture I posted is part of a large program. After I posted the question I reworked on the block diagram to create a base level example to try and figure out what was going wrong. Here is the base level example. I tried to get rid of the formula node in this. i just have a while loop and all LV operations. 
    I am trying to generate a random number, take the deviation^2 of the random number from 1 and then keep adding that cumulatively to make SSD. I want my SSD to begin with 0, everytime I stop and re-run the program. VI Attached. Please look at it and tell me. Thanks for the help in advance. 
    Attachments:
    ssd.vi ‏8 KB

Maybe you are looking for

  • Maintain diffrent prices for same material

    How to maintain different prices for same material (assume that the price of the the material is varying frequently that to with high margin) But my req is need to maintain N  values for same material .Is it possible?? For ex, 3 Jul Purchasing 20 Pc

  • Best way to upgrade my TBook to 10.4.x from 10.3.9 ?

    Can anyone tell me the tried and proven method for upgrading the OS on a G4 PowerBook 15-inch (Titanium). Specifically, I'm running 10.3.9 on it right now and want to upgrade it to 10.4.6. I have the install CDs for 10.4. I'll backup my user data and

  • F.5D - very urgent

    SAP Note 185787 suggest 1. Run report SAPF180A several times per period, e.g. once a week. It may also be useful that you run posting report SAPF180 more frequently (after SAPF180A). Or it might be better to execute SAPF180 once at the period-end. 2.

  • Premiere 5.5 - Retrieve/Recover Earlier Version of File?

    I accidentally saved over a Premiere file.  Can I retrieve an older file or is my work lost?  I know in Captivate I can retrieve older Cache files. Thank You

  • Why does it take 3 weeks to process my order for a simple disc?

    judt ordered snow leopard to start my upgrade process to Lion and can't understand why they say 3 weeks to process order then 3 days to ship the order??