XPATH statement help

I'm trying to write a little learning game in Flash, using
XML as the data source, but I can't get any XPATH statements to
work. I've written tons of XPATH against this structure in
JavaScript, and the XPATH statements evaluate properly in XML Spy,
but I always get "undefined" when I try to trace out the value of
the XPATH statements in Flash 8.
I'll post a valid (to XML Spy, that is) XPATH statement and
some sample code...
Thanks much for any help!
Mike

Okay, I'm experimenting now, I'll post if I figure out
anything useful. Although I admit, I'm not going to waste a lot of
time on this, if it looks like it's going to be overly difficult
(which it appears at this point it will be) given the limited
implementation, I'm just going to port the game to DHTML/Javascript
and use a decent XPATH implementation. I have probably 10 or more
relatively complex XPATH statements that I want to use, similiar in
logic to:
get all <theText> nodes whose parent <question>
node has a learningWheelUsage attribute set to "yes".
This is really simple in every other environment that I work
in, and I'm thinking it would just be easier to port the game to
something else than try to hack together a solution out of Flash's
limited implementation.
I'd want to put those into an array of course.. I haven't
given up hope yet, I'm going to do some more experimenting, but it
is FRUSTERATING!!!!! hahaha..
Thanks for the help!
Mike

Similar Messages

  • What's wrong with my XPath statement using dom4j?

    I'm pretty new to XML. However, I did pick up a book and I'm pretty much through it. I got a copy of dom4j and I created a sample XML file. I'm able to parse the data and find out the child elements of root but I'm having problems with using XPath no matter what I do. Here's my code:
    import org.dom4j.*;
    import org.dom4j.io.*;
    import java.util.*;
    import java.io.*;
    public class XMLACL {
      org.dom4j.Document doc;
      org.dom4j.Element root;
      XMLACL(String x) {
        String tempFile = System.getProperty("user.dir") + "/winsudo.xml";
        tempFile = tempFile.replace('\\', '/');
        SAXReader xmlReader = new SAXReader();
        try {
          doc = xmlReader.read(tempFile);
        catch (Exception e) {}
        root = doc.getRootElement();
        //treeWalk();
        //iterateRootChildren("grant");
        XPath xpathSelector = DocumentHelper.createXPath("/grant[@prompt='no']");  
        List results = xpathSelector.selectNodes(doc);
        for (Iterator iter = results.iterator(); iter.hasNext(); ) {
         Element element = (Element) iter.next();
          System.out.println(element.getName());
    }And here's my XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <config>
         <alias name="admin">
              <user>geneanthony</user>
              <user>mike</user>
              <user>rob</user>
         </alias>
         <grant prompt="no" runas="root" service="no">
              <user>geneanthony</user>
              <command>!ALL</command>
         </grant>
         <grant>
              <user>geneanthony</user>
              <group>users</group>
              <command>C:/Program Files/Mozilla Firefox/firefox.exe</command>
         </grant>
         <grant>
              <alias>admin</alias>
              <command>!Panels</command>
         </grant>
    </config>I'm currently getting this error:
    C:\Borland\JBuilder2005\jdk1.4\bin\javaw -classpath "C:\code\java\WinSudo\classes;C:\Borland\JBuilder2005\jdk1.4\jre\javaws\javaws.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\charsets.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\dnsns.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\ldapsec.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\localedata.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\ext\sunjce_provider.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\im\indicim.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\im\thaiim.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jce.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jsse.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\plugin.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\rt.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\sunrsasign.jar;C:\Borland\JBuilder2005\jdk1.4\lib\dt.jar;C:\Borland\JBuilder2005\jdk1.4\lib\htmlconverter.jar;C:\Borland\JBuilder2005\jdk1.4\lib\tools.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\jRegistryKey.jar;C:\Borland\JBuilder2005\jdk1.4\lib\hsqldb.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\dom4j-1.6.1.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\syntax.jar;C:\Borland\JBuilder2005\jdk1.4\jre\lib\IzPack-install-3.7.2.jar" winsudo.Main
    java.lang.NoClassDefFoundError: org/jaxen/JaxenException
         at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230)
         at org.dom4j.DocumentHelper.createXPath(DocumentHelper.java:121)
         at winsudo.XMLACL.<init>(XMLACL.java:26)
         at winsudo.Main.main(Main.java:15)
    Exception in thread "main"
    Can someone tell me what's wrong with my code. None of the samples I've seen came with the XML files so I don't know if I when I start the XPATH I need to use / for the root element, or // or a forward slash and the root name. Can I please get some help!

    Thank you! I didn't haven Jaxen I thought everything was in the package and I must have missed it in the tutorials. That resolved the dropouts and I think I'm good know. I couldn't think for the life of me what I was doing wrong!

  • Prepared Statement help -- cant get it to work :(

    Context initialcontext = new InitialContext();
              DataSource datasource = (DataSource)initialcontext.lookup("java:comp/env/XYZ");
              Connection conn = datasource.getConnection();                
              String UPDATE = "update query with ?s ";
              PreparedStatement pstmt = conn.prepareStatement(UPDATE);
              pstmt.setString(1,title);
              pstmt.setString(2,desc);
              pstmt.setInt(3,1);
              System.out.println("2a");
              pstmt.executeQuery(); ------- STUCK HERE
              System.out.println("2b");                              
              pstmt.close();
    It goes between 2a and 2b and just stops working.. no errors nothing...
    I have been trying to get this working the entire day... with no luck... any suggestions........

    I am familiar with a few dialects of SQL. I've never seen
    UPDATE <tbl> WITH...
    What RDBMS are you using? I just searched the mySQL documentation on the keyword WITH (case sensitive) and found no form of update that uses it.
    The ANSI SQL UPDATE statement takes the form...
    UPDATE <tbl> SET <col> = <value>[, <col> = <value>...]
    Also, you have three calls to setString, but only one ? in your String UPDATE indicating a position for a parameter.
    http://java.sun.com/docs/books/tutorial/jdbc/basics/prepared.html
    Hope this helps. If there is a form of UPDATE that uses WITH, please provide me with a reference link. I'm supposed to know SQL. :-)

  • Prepared statement help... pls...

    hey all... need help... this prepared statement is driving me mad... keeps throwing an error in my servlet.... can somebody pls help
         PreparedStatement updateWiki = con.prepareStatement("UPDATE sportinfo SET pageinfo,parent = (?,?) WHERE sport LIKE ? ");
              updateWiki.setString(1, wikipage);
              updateWiki.setString(2, parent);
              updateWiki.setString(3, sport);
              updateWiki.executeUpdate();
    am i missing something???
    thanks keith

    1. What is the error? Please post it.
    2. Try using the query like:
    UPDATE sportinfo SET pageinfo=?,parent=? WHERE sport LIKE ?
    and see if it still fails.

  • SQL statements:help

    here is a sample code of my application....
    int initialDelay = 10000; // start after 10 second
    int period = 10000*60*60*24*30; // repeat every month
    Timer timer = new Timer();
    TimerTask task = new TimerTask() {
    public void run() {
    try {
    MyDBConnection jdbc = new MyDBConnection();
    jdbc.init();
    Connection conn = jdbc.getMyConnection();
    Statement stmt = conn.createStatement();
    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
    Date date = new Date();
    String[] tbl = {"emticket","emattachment","emhistory","emtracker"};
    progTxt.setText("");
    Logs l = new Logs();
    l.append("Auto Archive");
    date.getTime();
    //Archive data
    progTxt.append("\n\n");
    progTxt.append(" Archiving Data...\n ");
    stmt.execute("select * into outfile 'c:/emticket " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate()");
    stmt.execute("select * into outfile 'c:/emattachment " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emattachment where EmID in (select EmID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
    stmt.execute("select * into outfile 'c:/emhistory " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emhistory where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
    stmt.execute("select * into outfile 'c:/emtracker " + dateFormat.format(date) + ".csv' fields terminated by ',' enclosed by '\"' lines terminated by '\\n' from emtracker where TicketID in (select TicketID from emticket where RcvDateTime between date_sub(curdate(),interval 90 day) and curdate())");
    progTxt.append("Done.\n\n");
    //Delete data
    progTxt.append(" Deleting Data... ");
    stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
    "_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
    System.out.println(stmt.getUpdateCount());
    progTxt.append("Done.\n\n");
    Here's what i want to do....I want to backup file for the current date back to 3 mos...e.g 2007-05-23 down to 2007-02-23...then delete the remaining records...before"02-23-2007 to 05-23-2007"....this is where the query part i that doesn't work....
    Delete data
    progTxt.append(" Deleting Data... ");
    stmt.execute("delete emticket, emattachment, emhistory, emtracker from emticket, emattachment, emhistory, emtracker where emattachment.EmID=emticket.EmID and emhistory.TicketID=emticket.TicketID and emtracker.TicketID=emtracker.TicketID and where RcvDateTime
    "_______"DATE_SUB(CURDATE(),INTERVAL 90 DAY) and CURDATE())");
    System.out.println(stmt.getUpdateCount());
    progTxt.append("Done.\n\n")
    I tried putting <>=which means not equal in the "_____"but it fails to work..can somebody help me to work out with this query.

    I don't know MySQL, but shouldn't you just use <= ? I also don't understand what the final part 'and CURDATE()' is for...

  • MySQL Select Statement Help Required

    I am trying to generate a report in VS 2008 (C#) using a mysql select statement but cannot get it right.
    I have groups that meet on a weekly basis on different days. I want to generate a report that shows me all the members that have not attended their group where they have missed 3 meetings in a row.
    Below is the select statement I have tried but it does not give me the results I am looking for. I have tried to look at all the meetings in a 4 week period but would prefer to look at the last 3 meetings that are recorded. Some groups might not record a meeting every week. So I want to look at the last 3 recorded meetings and count each members attendance and only report on the members with more than 3 meetings missed.
    SELECT COUNT(`groupattendance`.`Attended`) AS Attendance, `smallgroupform`.`MeetingDate`, `userinfo`.`FirstName`, `userinfo`.`Surname`, `smallgroup`.`GroupName`, `groupattendance`.`Attended`, `groupattendance`.`UserID`, `groupattendance`.`GroupID`
    FROM ((`anatomy`.`groupattendance` `groupattendance`
    INNER JOIN `anatomy`.`smallgroupform` `smallgroupform` ON `groupattendance`.`FormID` = `smallgroupform`.`FormID`)
    INNER JOIN `anatomy`.`userinfo` `userinfo` ON `groupattendance`.`UserID` = `userinfo`.`UserID`)
    INNER JOIN `anatomy`.`smallgroup` `smallgroup` ON `groupattendance`.`GroupID` = `smallgroup`.`GroupID`
    WHERE (`smallgroupform`.`MeetingDate` >= DATE_SUB(CURDATE(),INTERVAL 4 WEEK) AND `smallgroupform`.`MeetingDate` <= CURDATE()) AND `groupattendance`.`Attended` = 'False'
    GROUP BY `userinfo`.`UserID`
    HAVING Attendance >= 3
    Thanks,
    Garth.

    Hi Garth,
    Seems no one can help you directly. Try googling your SQL request. Someone may be able to help you. At this point its not really a Cr problem.
    One option is to get all the data and add filtering using the record selection formula.
    Thank you
    Don

  • Submit statement help - URGENT!!

    Hi..
    pls help me with this..
    requirement is like this..
    I am calling a report from another one. Say the calling report is first and the called is second. I am calling using submit statement.
    populated data in an internal table in second report.
    Returned to the first report and called third report and filled an internal table and came back to first report.
    Is there anyway that I can get those two ITABS at a time in the first report. Because i got to compare them.
    Pls suggest .. Thanks a lot!@!

    Hi,
    Check this example..
    *Send the internal table memory from the second report.
    EXPORT ITAB2 TO MEMORY ID 'REPORT2'.
    *Get the values from the second report.
    IMPORT ITAB2 FROM MEMORY ID 'REPORT2'.
    *Send the internal table memory from the third report.
    EXPORT ITAB3 TO MEMORY ID 'REPORT3'.
    *Get the values from the third report.
    IMPORT ITAB3 FROM MEMORY ID 'REPORT3'.
    Compare the internal table.
    IF ITAB2[] = ITAB3[].
    ENDIF.
    Thanks,
    Naren
    Message was edited by: Narendran Muthukumaran

  • Code too large for try statement - help :(

    Please help :(
              We are migrating our project from an older technology, Kiva from netscape
              (and about time we migrate) . Kiva uses template evaluation similar to
              jakarta velocity. So the fastest way we found was to translate kiva
              templates to JSPs via perl script. All is working fine except a bunch of
              JSPs which are too large for the compiler to handle. If we were not
              migrating and instead wroking from scratch we would have simply made the
              JSP's size smaller and used jsp:include, but in this case it will involve a
              lot of effort as that means changing a lot of business code.
              Basically what we get is "code too large for try statement". Is there anyway
              we can tell weblogic to put smaller code fragments in try/catch when it
              converts a JSP into java code.
              

              Haider,
              Have you seen the following Sun Bug Parade posting
              http://developer.java.sun.com/developer/bugParade/bugs/4210912.html
              Additionally, you may want to try the '-noTryBlocks' jsp compiler switch and see
              if it makes a difference
              See the following 6.1 URL
              http://edocs.bea.com/wls/docs61/jsp/reference.html#57805
              Chuck Nelson
              DRE
              BEA Technical Support
              

  • Oracle Spatial operator SQL statement help

    I have a 3D elevation point feature class (elev) and a polygon feature class (Building) loaded in Oracle Spatial. I am trying to update the "HEIGHT" attribute of the "Building" Feature class using the average elevation of "elev" feature class. Here below is the SQL statement I used, which generated the same value for all buildings. The avg(elevation) returns the average elevation of all points within all building polygons, not all points within ONE polygon.
    Please help and thanks.
    update building
    set height = (select avg(elevation)
    from elev e, building b
    where sdo_anyinteract(e.shape, b.shape) = 'TRUE');

    Hi,
    try this
    update building b
    set height = (select avg(elevation)
    from elev e where sdo_anyinteract(e.shape, b.shape) = 'TRUE');
    Udo

  • Case Statement Help needed

    case
    when datepart(mm,[SDate]) between '9' and '11' and datepart(mm,[PDate] ) between '9' and '11'
    Then 'Q1_'
    when datepart(mm,[SDate]) between '12' and '02' and datepart(mm,[PDate] ) between '12' and '02'
    Then 'Q2_'
    when datepart(mm,[SDate]) between '03' and '05' and datepart(mm,[PDate] ) between '03' and '05'
    Then 'Q3_'
    when datepart(mm,[SDate]) between '06' and '08' and datepart(mm,[PDate] ) between '06' and '08'
    Then 'Q4_'
    else 'N/A' end as QTR
    from DDA_2015_FSR
    Datatype for SDate and Pdate
    2014-09-01 00:00:00
    I need help with above case statement, When I run the case statement I get 'N/A FSY_2015   ' When I add the following where clause to validate the results. In my table I do have records for all four quarters, Except Q1, all other rows I get  'N/A
    FSY_2015   '
    Am i missing something? Can someone help me here?
    where
    datepart(m,[SDate]) 
    between
    '12'
    and
    '02'
    and  
    datepart(m,[PDate]
    between
    '12'
    and
    '02'
    FM

    There is no CASE statement in SQL; it is a CASE expression. Big difference. 
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Something_Report_Periods
    (something_report_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (something_report_name LIKE <pattern>),
     something_report_start_date DATE NOT NULL,
     something_report_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (something_report_start_date <= something_report_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --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

  • Switch Case Statement Help...

    Hello,
    I am trying to get my pages through Case Statement But...
    Can any one Help me.. here is my code..
    This is my Buttons Code... My buttons are on 1st Frame of My FLA..
    stop();
    btn1.addEventListener(MouseEvent.CLICK, varTest);
    btn2.addEventListener(MouseEvent.CLICK, varTest2);
    function varTest(event:MouseEvent):void
         var page = 1;
         gotoAndStop(20);
    function varTest2(event:MouseEvent):void
         var page = 2;
         gotoAndStop(20);
    and this is my 20th frame code. (here I'm checking variable)
    import flash.events.Event;
    addEventListener(Event.ENTER_FRAME,checkCaseMe);
    function checkCaseMe(event:Event)
         switch (page)
              case "1" :
                   info_txt.text = "page1";
                   break;
              case "2" :
                   info_txt.text = "page1";
                   break;
              default :
                   info_txt.text = "page00";
    When I test the movie.. Error Occured (Scene 1, Layer 'Actions', Frame 21, Line 6 1120: Access of undefined property page. )
    Can Anyone help please.. How do I correct this....???
    Thanks...

    You should learn to use the trace() function to help you troubleshoot code yourself.  In each of your button functions include:
    trace("btn clicked"); // will help you know for sure that the buttons are working
    And in frame 20, you should add a trace as well to determine whether you actually get there when you think you don't...
    trace("in frame 20");
    Lastly, your code for frame 20 is likely not what you need for a couple of reasons...
    1) If you think the ENTER_FRAME listener is used to detect/trigger when the timeline enters a frame, that is not what it does.  What it does is continually process the function that it calls at the frame rate of the file.  It is normally only used when you want to repeatedly trigger some functionality.
    2)  If you assign number values to the page variable, you do not want to use String values in your cases.
    All you should need in frame 20 is...
    switch (page)
         case 1 :
              info_txt.text = "page1";
              break;
         case 2 :
              info_txt.text = "page1";
              break;
         default :
              info_txt.text = "page00";

  • Case statement help

    Hi Gurus,
    I have a requirement like this,
    I want to extract the service request which closed in last month and opened in the last three months of closing month (close month -3).
    When open month is previous month and timestampdiff(tsi_month, open month(close month), openmonth(close month -3) then nbr of SRs.
    How do i bring the close month in open month value.
    Thanks

    I am trying to enter the following statement for the above requirment
    CASE WHEN "Core"."Close Date"."Close Month" = VALUEOF(PREVIOUS_MONTH) AND TimeStampDiff(SQL_TSI_Month, "Core"."Open Date"."Open Month" = VALUEOF(PREVIOUS_MONTH) , "Core"."Open Date"."Open Month" = VALUEOF(PREVIOUS_MONTH) - 3 ) <= 3 THEN 1 ELSE 0 END
    When i say okay, it gives the error
    [nQSError: 27002] Near <=>: Syntax error [nQSError: 26012] .
    Can anyone help me out.
    Thanks

  • Case statement help needed bit tricky

    I have a requirement for a Column Quarters which will idenitfy records based on their service and paid paids.
    Output of Column should be
    QTR
    FSY2015Q1
    Our Quarters start like this Q1= 9/1 /2014-11.30.2014 , Q2 12/1/2014 -02/28/2015, Q3: 3/1/2015 - 05/31/2015 Q4:06/01/2015 -08/31/2015.
    With the below Case statement  records that hit Q1 should be for the FSY upcoming.  records  in Sept, Oct, November of 2014, would actually be for FSY15Q1  (not FSY14Q1).   How can i correct
    this ?
    case
    when datepart(mm, Service_Through_Date ) between '9' and '11' and datepart(mm, c.paid_date ) between '9' and '11'
    Then 'Q1 '
    when datepart(mm, Service_Through_Date ) in ('01','02', '12' ) and datepart(mm, paid_date ) in ('01','02' , '12' )
    Then 'Q2 '
    when datepart(mm, Service_Through_Date ) between '03' and '05' and datepart(mm, paid_date ) between '03' and '05'
    Then 'Q3 '
    when datepart(mm, Service_Through_Date ) between '06' and '08' and datepart(mm, paid_date ) between '06' and '08'
    Then 'Q4 '
    else ' ' end + ' ' + 'FSY ' + '' + cast(datepart(Year, Service_Through_Date)as char(7)) as QTR
    FM

    Your best bet here is going to be to create a calendar table, which has your quarters in it.
    I wrote an article on them here: http://social.technet.microsoft.com/wiki/contents/articles/29260.tsql-calendar-functions-and-tables.aspx.
    For your particular scenario you'll need to add a column to the existing code, something like this:
    SELECT CASE WHEN DATEPART(MONTH,@date) IN (9,10,11) THEN 'FSY'+RIGHT(YEAR(@date)+1,2)+'Q1'
    WHEN DATEPART(MONTH,@date) IN (12) THEN 'FSY'+RIGHT(YEAR(@date)+1,2)+'Q2'
    WHEN DATEPART(MONTH,@date) IN (1,2) THEN 'FSY'+RIGHT(YEAR(@date),2)+'Q2'
    WHEN DATEPART(MONTH,@date) IN (3,4,5) THEN 'FSY'+RIGHT(YEAR(@date),2)+'Q3'
    WHEN DATEPART(MONTH,@date) IN (6,7,8) THEN 'FSY'+RIGHT(YEAR(@date),2)+'Q4'
    END AS fiscalQuarterName
    Once you have this column, you can simply join to the calendar table:
    SELECT service_through_date, paid_date, sc.fiscalQuarterName, pc.fiscalQuarterName
    FROM myTable t
    INNER JOIN calendar sc
    ON t.service_through_date = c.today
    INNER JOIN calendar pc
    ON t.paid_date = pc.today
    If you can't, or don't want to impliment this, you could solve the issue in your cast statement by moving the year into the CASE, like this:
    SELECT CASE WHEN DATEPART(MONTH, Service_Through_Date ) BETWEEN 9 AND 11 AND DATEPART(MONTH, c.paid_date) BETWEEN 9 AND 11 THEN 'FSY'+RIGHT(YEAR(Service_Through_Date)+1,2)+'Q1'
    WHEN DATEPART(MONTH, Service_Through_Date ) = 12 AND DATEPART(MONTH, c.paid_date) = 12 THEN 'FSY'+RIGHT(YEAR(Service_Through_Date)+1,2)+'Q2'
    WHEN DATEPART(MONTH, Service_Through_Date ) BETWEEN 1 AND 2 AND DATEPART(MONTH, paid_date) BETWEEN 1 AND 2 THEN 'FSY'+RIGHT(YEAR(Service_Through_Date),2)+'Q2'
    WHEN DATEPART(MONTH, Service_Through_Date ) BETWEEN 3 AND 5 AND DATEPART(MONTH, paid_date) BETWEEN 3 AND 5 THEN 'FSY'+RIGHT(YEAR(Service_Through_Date),2)+'Q3'
    WHEN DATEPART(MONTH, Service_Through_Date ) BETWEEN 6 AND 8 AND DATEPART(MONTH, paid_date) BETWEEN 6 AND 8 THEN 'FSY'+RIGHT(YEAR(Service_Through_Date),2)+'Q4'
    ELSE 'FSY'+RIGHT(YEAR(Service_Through_Date),2)
    END
    Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

  • Case Statement Help needed [Nested]

    Hi all,
    I need to write a case statement my requirement is
    ENC.EET.40 E_Disposition populated from either “E_ Status” field of HP_Response_table, “File Status” of HP _TTT_Response_Table,
    or “E_Status” of DDA_R_Table. If no data in any of these fields, default to “Submitted”
     So my case stmt should look like
    case when E_Status is null then 'SUBMITTED'
    when   e_status is null then 'Submitted'
    when    FileStatus is null then 'Submitted'
    Else case when E_status is not null then ............?????????????
    else case when
    Im Confused.. Can someone help me ?
    FM

    select ...
    coalesce (resp.E_Status, resp2.FileStatus, dda.E_Status, 'Submitted')
    from ...
    Obviously I have used alias for the respective tables according to your logic.

  • SQL select statement help

    Say i have a table that has the following fields...
    ID    field1    field2   field3  field4   field5   field6   field7
     1        1           2         E         NW     SW  
         n         n
     2        1           2         E         NE      SW  
         n          n 
     3        1           3         W        NE      SE  
          n          n 
    10,000 plus entries in this table:  it is state quarter quarter data if it helps... 
    So i was handed a list on paper that has about 500 of these quarters from the above said table but there is no ID. I am having a someone build an excel spread
    sheet in the fashion above but the only fields will be as follows
    ID(NOT THE SAME AS ABOVE)  field1   field2  field3 field4  field5
    1                                                  
    1           1         W      NW    NE
     500 or so entries in this table
    no field 6 or 7
    how would i go about selecting all the fields from the top table that match exactly fields 1-5 in the excel sheet?
    and no there are no duplicate entries in the top table.
    thanks,
    james
    dogdaynoon

    Is field6 and field7 nullable fields in yourtable?
    If yes you can simply ignore them in your insert statements
    If you're directly dumping the contents of excel to table then it would be like
    INSERT YourTable (field1,field2,field3,field4,field5)
    SELECT field1,field2,field3,field4,field5
    FROM OPENROWSET(....) AS f
    if you're populating a tsgaing table you can do like this
    INSERT YourTable (field1,field2,field3,field4,field5)
    SELECT field1,field2,field3,field4,field5
    FROM StagingTable s
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for