Help with SELECT command

I have 2 tables (Table1 and Table2) , I want to select all the rows form Table1 and show in an extra column what rows does exist or not in Table2.
Something like that:
Column1, Column2, ExistInTable2
a a YES
b b YES
c c NO
d d YES
e e NO
How do i do that SQL statement?
SELECT column1, column2, ¿xxxxx? FROM Table1?
Thanks

I think you want the second option:
SQL> SELECT d.*,DECODE(e.deptno,NULL,'NO','YES')
  2    FROM dept       d
  3        ,emp        e
  4   WHERE d.deptno   = e.deptno(+)
  5  /
    DEPTNO DNAME          LOC           DEC
        20 RESEARCH       DALLAS        YES
        30 SALES          CHICAGO       YES
        30 SALES          CHICAGO       YES
        20 RESEARCH       DALLAS        YES
        30 SALES          CHICAGO       YES
        30 SALES          CHICAGO       YES
        10 ACCOUNTING     NEW YORK      YES
        20 RESEARCH       DALLAS        YES
        10 ACCOUNTING     NEW YORK      YES
        30 SALES          CHICAGO       YES
        20 RESEARCH       DALLAS        YES
        30 SALES          CHICAGO       YES
        20 RESEARCH       DALLAS        YES
        10 ACCOUNTING     NEW YORK      YES
        40 OPERATIONS     BOSTON        NO
15 rijen zijn geselecteerd.
SQL> select deptno
  2       , dname
  3       , nvl2((select empno from emp where deptno = dept.deptno and rownum = 1),'YES','NO')
  4    from dept
  5  /
    DEPTNO DNAME          NVL
        10 ACCOUNTING     YES
        20 RESEARCH       YES
        30 SALES          YES
        40 OPERATIONS     NO
4 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.

    Before I go into a lengthy explanation of the problem: Can anyone help with Double Command issues. This a specific keyboard question and they do not seem to know.
    Thanks much.
    Emile

    Choose Force Quit from the Apple menu and close Mail from there.
    (103661)

  • Help with SELECT - selecting range of numbers

    Hi,
    I need a help with SELECT statement. I want to select Dates starting from today and ending 30 days back. So the result would be like:
    TRUNC(SYSDATE)
    TRUNC(SYSDATE) - 1
    TRUNC(SYSDATE) - 2
    TRUNC(SYSDATE) - 3
    TRUNC(SYSDATE) - 30I was thinking to simply select truncated SYSDATE in first column, and in second column numbers 0, 1, 2, ... 30. Then I would simply do a difference first column - second column. But how to select such sequence of numbers? I don't want to select each number (date) in separate select statement and then unioning them.
    Does anybody have an idea?
    Thanks for help, Dan

    SQL> select trunc(sysdate) - level + 1 as dt
      2  from dual
      3  connect by level <= 31
      4  ;
    DT
    07/01/2013
    06/01/2013
    05/01/2013
    04/01/2013
    03/01/2013
    02/01/2013
    01/01/2013
    31/12/2012
    30/12/2012
    29/12/2012
    28/12/2012
    27/12/2012
    26/12/2012
    25/12/2012
    24/12/2012
    23/12/2012
    22/12/2012
    21/12/2012
    20/12/2012
    19/12/2012
    DT
    18/12/2012
    17/12/2012
    16/12/2012
    15/12/2012
    14/12/2012
    13/12/2012
    12/12/2012
    11/12/2012
    10/12/2012
    09/12/2012
    08/12/2012
    31 rows selected

  • Help with selecting chuncks of data from a table

    Hi all,
    I need help with a query that should do the following.
    I have a table with vessel messages, and I need to get the last "NumMsgs" messages from a group of vessels.
    The problem I have is that if I order the table by Vessel_ID, MessageDate DESC, I can´t do ROWNUM < NumMsgs (<-- Then number of messages to be shown is a user parameter)
    I know it should be something like:
    select * from (
    select *
    from Messages m
    where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
    order by m.V_ID, m.MESSAGEDATE desc
    where rownum < :NumMsgs
    Any ideas?
    Thanks in advance !

    Hi,
    What about :
    select *
    from (
    select m.*, row_number() (order by m.V_ID, m.MESSAGEDATE desc) rn
    from Messages m
    where TRIM(m.V_ID) = '11597' /* I was trying for a single vessel atm */
    where rn < :NumMsgsAnyway, I don't very well understand your problem, your query work fine, see for example :
    SQL> ed
    Wrote file afiedt.buf
      1  select object_name, object_id
      2  from
      3  (select object_name, object_id, row_number() over (order by object_id desc) as rn
      4   from dba_objects)
      5* where rn < 4
    SQL> /
    PS_TL_MTCHD_118     71763
    PS_TL_MTCHD_117     71762
    PS_TL_MTCHD_116     71761
    SQL> ed
    Wrote file afiedt.buf
      1  select object_name, object_id
      2  from
      3  (select object_name, object_id
      4   from dba_objects
      5   order by object_id desc)
      6* where rownum < 4
    SQL> /
    PS_TL_MTCHD_118     71763
    PS_TL_MTCHD_117     71762
    PS_TL_MTCHD_116     71761
    SQL> Nicolas.
    Message was edited by:
    N. Gasparotto

  • Help with a Command script

    Hello,
    Awhile back someone wrote the following script for me. The
    idea was to make a comman that would allow me to reduce an image
    down to 400 pixel width without loss of scale. I want to have a
    similiar command that will reduce a large image down to 400 pilel
    height without loss of scale. I fiddled with the command for width
    but can't get it to work for height. Can I get some help rewriting
    the following command to work for 400 pixel height? Thanks.
    // User Variables
    var width = 400;
    // Command
    var dom = fw.getDocumentDOM();
    var scale = width/dom.width;
    var height = dom.height * scale;
    dom.setDocumentImageSize({left:dom.left, top:dom.top,
    right:dom.left+width, bottom:dom.top+height},
    {pixelsPerUnit:dom.resolution, units:dom.resolutionUnits});

    Tom Hersh wrote:
    > I did try it that way. But I could not get it to work.
    The word "scale" is critical, but I switching did not help.
    Just switch the variables word for word. Height for width and
    width for
    height.
    // User Variables
    var width = 400;
    // Command
    var dom = fw.getDocumentDOM();
    var scale = width/dom.width;
    var height = dom.height * scale;
    dom.setDocumentImageSize({left:dom.left, top:dom.top,
    right:dom.left+width,
    bottom:dom.top+height}, {pixelsPerUnit:dom.resolution,
    units:dom.resolutionUnits});
    // User Variables
    var height = 400;
    // Command
    var dom = fw.getDocumentDOM();
    var scale = height/dom.height;
    var width = dom.width * scale;
    dom.setDocumentImageSize({left:dom.left, top:dom.top,
    right:dom.left+width,
    bottom:dom.top+height}, {pixelsPerUnit:dom.resolution,
    units:dom.resolutionUnits});
    Once you see this script, it's not hard to see what it is
    doing.
    This is the Fireworks generated script scaling just the
    height of an
    image to 400 px from 640x480 px.
    fw.getDocumentDOM()
    .scaleSelection(0.83281248807907104, 0.83333333333333337,
    "autoTrimImages transformAttributes");
    This works on all 640x480 images. Throw in a 700x480 and it
    won't.
    I'm assuming, very few people in here (myself included),
    would be able
    to transform this into something that would account for
    varying widths
    as senocular did.
    SKB

  • Help with Expect command to change config on hundreds of ASA's.

    Hi All,
    I'm looking for some help with the Expect command to automate some tasks, I'm certainly no programmer but I am struggling, here is an example of my script.
    #!/usr/bin/expect -f
    # This simple Expect script will add a new Syslog destination in
    # Cisco switches (IOS based)
    # We assume here that all switches uses the same credentials
    # for the administrative tasks
    # Define variables
    set password "site1"
    set enablepassword "site1"
    # Define all the switches to be reconfigured (separated by spaces)
    set switches "site1 site2 site3"
    # Main loop
    foreach switch $switches {
            puts "Processing switch: $switch";
            # Open the telnet session:
            spawn telnet $switch
            # Perform authentication
            expect "Password:"
            send "$password\r"
            expect ">"
            # Switch to enable mode
            send "en\r"
            expect "Password:"
            send "$enablepassword\r"
            expect "#"
            # Enable configuration mode (terminal)
            send "conf t\r"
            expect "#"
            # Modify VLAN1
            send "interface vlan1\r"
            expect "#"
         # Change VLAN1 Description to Uppercase
            send "description INSIDE\r"
            expect "#"
            send "exit\r"
            expect "#"
            # Save config to NVRAM
            send "wr\r"
            expect "#"
            #Logging out
            send "exit\r"
            expect eof
    In the example this works fine for SITE1 passing the credentials SITE1 as the default password and SITE1 as the enable password.  I need to do usernames and passwords that are different for each site.  I have to make some changes across hundreds of ASA's to terminating tunnels to a new location.  Can anyone help out in how to do this, I know I am close I just need it to read, siteA, username, both passwords from a text file, etc
    Greg

    Hello,
    try to modify this example to your needs ->
    http://www.bitpapers.com/2012/04/cisco-changing-configurations-of-many.html
    Best Regards
    Please rate all helpful posts and close solved questions

  • Need help with select that month range with flexible first date

    Hello everyone,
    I am trying to create a selection of month range (will be in a WITH clause) for a report to display monthly data. But the first month start date can be any date. (Not necessarily the first date of the month)
    Examples:
    Report input parameters:
    Start Date: 08/10/12
    End Month: Dec 2012
    I was trying to build a with select that will list
    Month_Start, Month_End
    08/10/12, 31/10/12
    01/11/12, 30/11/12
    01/12/12, 31/12/12
    OR
    Month_Start, Next_Month
    08/10/12, 01/11/12
    01/11/12, 01/12/12
    01/12/12, 01/01/13
    End month is optional, so if no value the select will list only
    08/10/12, 01/11/12
    Oracle Database Details is
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    PL/SQL Release 11.1.0.7.0 - Production
    My code so far is
    VARIABLE  P50_START_DATE  VARCHAR2 (10)
    VARIABLE  P50_END_MONTH    VARCHAR2 (10)
    EXEC  :P50_START_DATE  := '10/10/2012';
    EXEC  :P50_END_MONTH   := '31/12/2012';
      SELECT  to_char(:P50_START_DATE) AS start_date
            ,  ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), 1) AS next_month
      FROM dual
      union
       SELECT to_char(ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM-1)) AS start_date
       ,      ADD_MONTHS( TRUNC(to_date(:P50_START_DATE,'DD/MM/YYYY'),'MONTH'), ROWNUM) AS next_month
       --, rownum
       from all_objects
       where
       rownum <= months_between(to_date(NVL(:P50_END_MONTH, :P50_START_DATE),'DD/MM/YYYY'), add_months(to_date(:P50_START_DATE,'DD/MM/YYYY'), -1))
       and rownum > 1If I put comment – on line and rownum > 1, as
    -- and rownum > 1The result I get is
    START_DATE                     NEXT_MONTH               
    01/10/12                       01/10/12                 
    01/11/12                       01/11/12                 
    01/12/12                       01/01/13                 
    10/10/2012                     01/11/12    But when I try to remove the duplicate period (of the first month) out by restrict rownum, it do not return any rows for the second select at all. The result I get is:
    START_DATE                     NEXT_MONTH               
    10/10/2012                     01/11/12    Can anyone advise what wrong with the select statement ?
    Thanks a lot in advance,
    Ann

    Hi,
    Here's one way:
    WITH   params      AS
         SELECT     TO_DATE (:p50_start_date, 'DD/MM/YYYY')     AS start_date
         ,     TO_DATE (:p50_end_month,  'DD/MM/YYYY')     AS end_date
         FROM     dual
    SELECT     GREATEST ( start_date
               , ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                            , LEVEL - 1
              )               AS month_start
    ,     LEAST     ( end_date
              , ADD_MONTHS ( TRUNC (start_date, 'MONTH')
                          , LEVEL
                        ) - 1
              )               AS month_end
    FROM    params
    CONNECT BY     LEVEL     <= 1 + MONTHS_BETWEEN ( end_date
                                      , TRUNC (start_date, 'MONTH')
    ;:p50_end_month doesn't have to be the last day of the month; any day will work.
    If you want to generate a Counter Table containing the integers 1 througn x in SQL, you could say
    SELECT  ROWNUM  AS n
    FROM    all_objects
    WHERE   ROWNUM  <= x
    ;but, starting in Oracle 9.1, it's much faster to say
    SELECT  LEVEL   AS n
    FROM    dual    -- or any table containing exactly 1 row
    CONNECT BY  LEVEL <= x
    ;Also, x can be greater than the number of rows in all_objects.

  • Need help with select within select - daterange

    I use Crystal Reports v12.3.0.601 - I am a beginner.
    Problem:
    TABLE: ACCOUNTBILLFEE
    Columns are   
    FOLDERRSN
    STAMPDATE
    BILLNUMBER
    PAYMENTAMOUNT
    There are over 500,000 rows/ records...
    And I need to report the FOLDERRSN which has at least one {ACCOUNTBILLFEE.STAMPDATE} in DateTime
    (2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59)
    Out-put required is:
    FOLDERSN | STAMPDATE | BILLNUMBER   | PAYMENTAMOUNT
    Group by FOLDERRSN
    1010234               May01,2014                 1111                      25000
                                  May25, 2014                1112                       5000
                                  Jan 05, 2013                  998                          500
    1034567                May5, 2014                11325                       5000
    1033999                May15, 2014               6752                       15000
                                  Dec5 , 2011                1132                       25000
    Please help -
    The critical part for me, is to display  payments not within the date range in 'select expert' statement.
    Currenlty my report reflects only payments for FOLDERRSN, where {ACCOUNTBILLFEE.STAMPDATE} in DateTime
    (2014, 05, 01, 00, 00, 01) to DateTime (2014, 05, 31, 23, 59, 59) and not other payments outside the date range specified.
    Thank you for your time.

    Hi Abilash,
    This worked !!!
    My brother helped me with it here....ofcourse you have intiated the intial idea.
    It worked when i used the following SQL at 'Add Command'
    Select * from DATABASE_NAME.ACCOUNTBILLFEE A
    Where A.FOLDERSN = any ( select B.FOLDERSN from DATABASE_NAME.ACCOUNTBILLFEE B
    where B.STAMPDATE >= TO_DATE('20140501', 'YYYYMMDD')
    AND  B.STAMPDATE <= TO_DATE('20140531', 'YYYYMMDD'))
    Excellent support - Thank you so much for your immediate attention and response.
    I know, how hard it is to understand someones requirement and suggest solutions.
    You are the best and most helpful I have ever come across in my life.
    Thank you for your kind heart and extending help to me.
    Regs,
    Sridhar Lam

  • Help with selecting files from script menu or drag and drop

    I found this scale images applescript online. It works great when a bunch of files is dragged on top of the script but I would like it to also work when a folder or group of files is selected in the Finder and I activate it from the scripts menu.
    I can't get my on run statement to work. I'm not really an Applescript guy so I'm really just asking if someone can help finish what I started in this on run.
    -- save in Script Editor as Application
    -- drag files to its icon in Finder
    property target_width : 120
    property save_folder : ""
    on run
    tell application "Finder"
    activate
    set folder_path to quoted form of (POSIX path of (the selection as alias))
    set theItems to every file of folder_path
    end tell
    end run
    on open some_items
    -- do some set up
    tell application "Finder"
    -- get the target width, the default answer is the property target_width
    set new_width to text returned of ¬
    (display dialog "Target width:" default answer target_width ¬
    buttons {"OK"} default button "OK")
    if new_width as integer > 0 then
    set target_width to new_width
    end if
    -- if the save_folder property has not been set,
    -- set it to the folder containing the original image
    if save_folder is "" then
    set save_folder to ¬
    (container of file (item 1 of some_items) as string)
    end if
    -- get the folder to save the scaled images in,
    -- default folder is the property save_folder
    set temp_folder to ¬
    choose folder with prompt ¬
    "Save scaled images in:" default location alias save_folder
    set save_folder to temp_folder as string
    end tell
    -- loop through the images, scale them and save them
    repeat with this_item in some_items
    try
    rescaleand_save(thisitem)
    end try
    end repeat
    tell application "Image Events" to quit
    end open
    on rescaleand_save(thisitem)
    tell application "Finder"
    set new_item to save_folder & "scaled." & (name of this_item)
    end tell
    tell application "Image Events"
    launch
    -- open the image file
    set this_image to open this_item
    set typ to this_image's file type
    copy dimensions of this_image to {current_width, current_height}
    scale this_image by factor (target_width / current_width)
    save this_image in new_item as typ
    end tell
    end rescaleandsave

    When items are dragged to your script's icon they are passed in to the on open handler, so this triggers:
    on open some_items
    and the dragged items are passed in as some_items
    In contrast, when you double-click on the script, or invoke it via the Script menu, this runs the on run handler:
    on run
      tell application "Finder"
        activate
        folder_path to quoted form of (POSIX path of (the selection as alias))
        set theItems to every file of folder_path
      end tell
    end run
    However, there's nothing in this block that actually does anything with the selection - you (dangerously) assume that the selection is a folder (you really should check first), and just set theItems to every file in that folder then you exit.
    So to do what you want you'll need to edit your run handler to filter the selection and pass files over to the code that does the hard work.
    You already have the basis for this - your rescaleandsave() handler, so it's just a matter of identifying the files in the selection and passing those over to that handler:
    on run
      tell application "Finder"
        set cur_selection to (get selection) -- get the selection
        repeat with each_item in cur_selection -- iterate through
          if class of each_item is folder then -- do we have a folder?
            set theFiles to every file of each_item -- if so, get its contents
            repeat with each_file in theFiles -- iterate through them
              my rescaleand_save(eachfile) -- and process them
            end repeat
          else if class of each_item is document file then -- do we have a file selected?
            my rescaleand_save(eachitem) -- if so, process it
          end if
        end repeat
      end tell
    end run
    So the idea here is that the run handler gets the selection and works through the (potentially-numerous) items. For each selected item it checks whether its a folder or a file, if its a folder it gets all the files within and passes them to the rescaleandsave handler.
    Note that this is not recursive - it won't catch files within folders within folders - since it only looks at the top level of selected folders, but it wouldn't be hard to rework the script to handle that if that's what you need.

  • Help with select code??

    I have a calendar program in jsp. The users can enter description for the dates. These dates are stored in the database. I need to provide colors to those dates,which have a value 'N' in the weekender field. Am able to write the query, but am not able to provide the color. how can i do it? please help..
    <%@ page import="java.util.List"%>
    <%@page import="java.sql.*, java.util.*, java.text.*" %>
    <%@page import="java.sql.Connection, java.sql.DriverManager,java.sql.ResultSet,java.sql.SQLException" %>
    <html>
    <head>
    <title>Print a month page.</title>
    <meta name="version">
    <script>
         var lastId = "";
         var curId  = "";
         function selectDate(f)
                   if(document.forms[0].lastDateId != null)
                   lastId = document.forms[0].lastDateId.value;
                   if(lastId != document.forms[0].todayId.value)
                     if(document.getElementById(lastId).title == "")
                      document.getElementById(lastId).style.backgroundColor='white';
                           if(f.id != document.forms[0].todayId.value)
                      document.getElementById(f.id).style.backgroundColor='blue';
                            document.forms[0].lastDateId.value=f.id;
                        curId = f.id;
                     document.getElementById("descr").style.visibility='visible';
                     document.forms[0].descText.value = f.title;
         function setTitle()
              document.getElementById(curId).title=document.forms[0].descText.value;
    if(document.forms[0].descText.value == "" && curId != document.forms[0].todayId.value)
    document.getElementById(curId).style.backgroundColor='white';
               else
    if(document.forms[0].list.value == "" )
    document.forms[0].list.value = curId+":"+document.getElementById(curId).title;
                   else
                   list = replaceList(document.forms[0].list.value,curId);
                   list = list+","+curId+":"+document.getElementById(curId).title;
                   document.forms[0].list.value = list;
              document.getElementById("descr").style.visibility='hidden';
         function replaceList(list,id)
              arr = list.split(",");
              newlist = "";
              for(i in arr)
                   if(arr.match(id) == null)
                        if(newlist == "")
                             newlist = arr[i];
                             else
                             newlist += ","+arr[i]+",";
              return newlist
         function showCalendar()
              location.href="CalendarPage.jsp?year="+document.forms[0].year.value;
    </script>
    </head>
    <body bgcolor="#c6d9e4">
    <%
    Connection con = null;
    response.setContentType("text/html");
         try
         String driverName = "com.mysql.jdbc.Driver";
         Class.forName(driverName);
         String serverName = "192.168.10.5";
         String mydatabase = "Trainees";
         String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
         String username = "venkat";
         String password = "venkat";
         con = DriverManager.getConnection(url, username, password);
         Statement stmt = null;
         ResultSet rset = null;
         PreparedStatement PREPstmt1;
         stmt = con.createStatement();     
    String year = request.getParameter("year");
    out.println("year value is : "+year);
    String date="",descr="";
         String list = request.getParameter("list");
    if(list != null)
              String dateDescrList[] = list.split(",");
              for(int i=0;i<dateDescrList.length;i++)
              String listObj = dateDescrList[i];
              if(!listObj.equals("") || !listObj.trim().equals(""))
         date= year+"-"+listObj.substring(0,listObj.indexOf(":"));
                        descr = listObj.substring(listObj.indexOf(":")+1);
                        out.println("date is : "+date);
                        out.println("description is : "+descr);               
    String query = "insert into Holiday(HolidayDate, Description, Weekender) VALUES (?, ?, 'N')";
              PREPstmt1=con.prepareStatement(query);
         PREPstmt1.setString(1,date);
         PREPstmt1.setString(2,descr);
         PREPstmt1.executeUpdate();
    catch(Exception e)
    System.err.println("Exception: " + e.getMessage());
    finally
    try
    if(con != null)
    con.close();
    catch(SQLException e)
    %>
    <%
    Calendar c = Calendar.getInstance( );
         boolean yyok = false;
         int yy = 0, mm = 0;
         String yyString = String.valueOf(c.get(Calendar.YEAR)); //setting calendar with current year
    String STyear = request.getParameter("year"); //to get selected year
    if(STyear != null) //If an year is selected, then set that year. Else Current Year
    yyString=STyear;
         if (yyString != null && yyString.length() > 0)
         try
         yy = Integer.parseInt(yyString);
    yyok = true;
         catch (NumberFormatException e)
         out.println("Year " + yyString + " invalid");
    if (!yyok)yy = c.get(Calendar.YEAR);
    mm = c.get(Calendar.MONTH);
    String todayId = "";
    %>
    <form method=get action="CalendarPage.jsp">
    Enter Year : <select name="year">
    <%
         for(int i=2000;i<=2015;i++)
              if(i==Integer.parseInt(yyString))
    %>
                   <OPTION SELECTED= <%=i%> > <%=i%> </option>
    <%
              else
    %>
                   <OPTION VALUE= <%=i%> > <%=i%> </option>
    %>      
    <%
    %>
         </select>
    <input type="button" value="Display" onClick="showCalendar()">
    <br><br>
    <div id="descr" style="visibility:hidden">Enter Description : <input type="text" name="descText" value=""> </div>
    <br>
    <%
              String driverName = "com.mysql.jdbc.Driver";
         Class.forName(driverName);
         String serverName = "192.168.10.5";
         String mydatabase = "Trainees";
         String url = "jdbc:mysql://" + serverName + "/" + mydatabase;
         String username = "venkat";
         String password = "venkat";
         con = DriverManager.getConnection(url, username, password);
         Statement stmt = null;
         ResultSet rset = null;
         PreparedStatement PREPstmt1;
         stmt = con.createStatement();     
    rset=stmt.executeQuery("select count(*) from Holiday where YEAR(HolidayDate)='"+yyString+"'");
    int cnt=0;
    boolean ALflag=false;
    while(rset.next())                         
         cnt= rset.getInt(1);
    out.println("count is : "+cnt);
         if(cnt>1)
    ALflag=true;
    %>
    <%
    rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
    int cnte=0;
    boolean SELflag=false;
    while(rset.next())                         
    cnte = rset.getInt(1);
    out.println("count is : "+cnte);
    if(cnte>1)
    SELflag=true;
    %>
    <%!
    String[] months = {
                   "January", "February", "March",
                   "April","May", "June",
                   "July", "August","September",
                   "October", "November", "December"
    int dom[] = {
              31, 28, 31, 30,
              31, 30, 31, 31,
              30, 31, 30, 31
    %>
    <%
    int leadGap = 0;
    %>
    <table border="0" width="100%" align="Left">
    <%
         GregorianCalendar calendar =null;
         for(int j=0;j<12;j++)
              calendar = new GregorianCalendar(yy, j, 1);     
              if(j==0 || j%3==0)
    %>
         <tr>
    <%
    %>
              <td halign="top" >
              <table border="1" width="33%" align="Left"><tr align="right">
              <th colspan=7>
              <%= months[j] %>
              <%= yy %>
                   </th>
                   </tr>
                   <tr>
                        <td>Sun<td>Mon<td>Tue<td>Wed<td>Thu<td>Fri<td>Sat
                   </tr>
         <%
              leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
              int daysInMonth = dom[j];
              if (calendar.isLeapYear(calendar.get(Calendar.YEAR)) && j == 1)
              ++daysInMonth;
              out.println("<tr>");
              out.println(" ");
              for (int i = 0; i < leadGap; i++)
                   out.print("<td> </td>");
              for (int iday = 1; iday <= daysInMonth; iday++)
                   out.println("<td>");
    int dayOfWeek = (leadGap + iday) % 7;
         GregorianCalendar today = new GregorianCalendar();
         if(today.get(Calendar.DATE) == iday && today.get(Calendar.MONTH) == j)
    todayId = iday+"-"+(j+1);
    %>
    <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccc00" title="" ><%=iday %></div>
    <%
    else
    if(dayOfWeek <= 1)
    String str = yyString+"-"+(j+1)+ "-"+ iday;
    if((dayOfWeek == 0) && (ALflag==false))
         String query = "insert into Holiday VALUES ('" + str + "','Saturday','Y')";
         stmt=con.createStatement();
         stmt.executeUpdate(query);
    else if ((dayOfWeek == 1) && (ALflag==false))
         String query = "insert into Holiday VALUES ('" + str + "','Sunday','Y')";
         stmt=con.createStatement();
         stmt.executeUpdate(query);
    %>
    <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccccc" title=""> <%=iday %></div>
    <%
    else
              %>
    <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:white" title="" ><%=iday %></div>
              <%
                   out.println("</td>");
                   if(calendar.getActualMaximum(Calendar.DAY_OF_MONTH) == iday)
                        out.println("</td></tr></table>");
                   else if ((leadGap + iday) % 7 == 0)
                        out.println("</tr>");
                        out.println("<tr>");
    %>
              </td>
    <%
              if((j+1)%3==0)
    %>
              </tr>
    <%
    %>
    <input type="hidden" name="lastDateId" value="<%=todayId%>">
    <input type="hidden" name="todayId" value="<%=todayId%>">
    <input type="hidden" name="list" value="">
    <input type="submit" value="Submit" onClick="setTitle()">
    </form>
    </body>
    </table>
    </html>
    This is the extract of the above code. This is how i have provided the query. In which part of my above code should i provide the coloring aspect. If the (SELflag==false), then i want to provide the color. where should i give? please help
    <%
    rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
    int cnte=0;
    boolean SELflag=false;
    while(rset.next())                         
    cnte = rset.getInt(1);
    out.println("count is : "+cnte);
    if(cnte>1)
    SELflag=true;
    %>

    Here is the calendar code, which i have used. Where should i use the code to check . i am able to get the count of user inputted days. i want to use the code,
    if(SELflag==false)
    give color.
    where can i give this if code, to get the color?
    <%
    rset=stmt.executeQuery("select count(*) from Holiday where Weekender='N'");
    int cnte=0;
    boolean SELflag=false;
    while(rset.next())                         
    cnte = rset.getInt(1);
    out.println("count is : "+cnte);
    if(cnte>1)
    SELflag=true;
    %>
    <%!
    String[] months = {
                     "January", "February", "March",
                     "April","May", "June",
                     "July", "August","September",
                     "October", "November", "December"
    int dom[] = {
               31, 28, 31, 30,
               31, 30, 31, 31,
               30, 31, 30, 31
    %>
    <%
    int leadGap = 0;
    %>
    <table border="0" width="100%" align="Left">
    <%
         GregorianCalendar calendar =null;
         for(int j=0;j<12;j++)
              calendar = new GregorianCalendar(yy, j, 1);     
              if(j==0 || j%3==0)
    %>
                 <tr>
                     <%
    %>
              <td halign="top" >
              <table border="1" width="33%" align="Left"><tr align="right">
              <th colspan=7>
              <%= months[j] %>
              <%= yy %>
                   </th>
                   </tr>
                   <tr>
                        <td>Sun<td>Mon<td>Tue<td>Wed<td>Thu<td>Fri<td>Sat
                   </tr>
         <%
              leadGap = calendar.get(Calendar.DAY_OF_WEEK)-1;
              int daysInMonth = dom[j];
              if (calendar.isLeapYear(calendar.get(Calendar.YEAR)) && j == 1)
              ++daysInMonth;
              out.println("<tr>");  
              out.println(" ");
              for (int i = 0; i < leadGap; i++)
                    out.print("<td> </td>");
              for (int iday = 1; iday <= daysInMonth; iday++)
                       out.println("<td>");
                      int dayOfWeek = (leadGap + iday) % 7;
                       GregorianCalendar today = new GregorianCalendar();
         if(today.get(Calendar.DATE) == iday && today.get(Calendar.MONTH) == j)
              todayId = iday+"-"+(j+1);
         %>
              <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccc00" title="" ><a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
         <%
           else
               if(dayOfWeek <= 1)
                    String str = yyString+"-"+(j+1)+ "-"+ iday;
                       if((dayOfWeek == 0) && (ALflag==false))
                        String query = "insert into Holiday VALUES ('" + str + "','Saturday','Y')";
                        stmt=con.createStatement();
                        stmt.executeUpdate(query);
                    else if ((dayOfWeek == 1) && (ALflag==false))
                        String query = "insert into Holiday VALUES ('" + str + "','Sunday','Y')";
                        stmt=con.createStatement();
                        stmt.executeUpdate(query);
              %>
              <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:#cccccc" title=""> <a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
              <%
               else
                  %>
                    <div id="<%=((j+1)+"-"+iday)%>" onClick="selectDate(this)" style="background-color:white" title="" ><a href="#" style="text-decoration:none;color:808080"><%=iday %> </a></div>
                   <%
                   out.println("</td>"); 
                   if(calendar.getActualMaximum(Calendar.DAY_OF_MONTH) == iday)
                        out.println("</td></tr></table>");
                    else if ((leadGap + iday) % 7 == 0)
                        out.println("</tr>");
                        out.println("<tr>");
    %>
              </td>
    <%
              if((j+1)%3==0)
    %>
              </tr>
    <%
    %>
    <input type="hidden" name="lastDateId" value="<%=todayId%>">
    <input type="hidden" name="todayId" value="<%=todayId%>">
    <input type="hidden" name="list" value="">
    <input type="submit" value="Submit" onClick="setTitle()">
    </form>
    </body>
    </table>
    </html>

  • Help with Select Decode Round

    Hi, If anyone could help me with this. I need to round all these numbers in the DECODE but without repeating ROUND.
    This way works:
    SELECT title "Title", category "Category",retail "Current Price",
    DECODE(category,
    'COMPUTER',(ROUND(retail * 1.1,2)),
    'FITNESS', (ROUND(retail * 1.15,2)),
    'SELF HELP', (ROUND(retail * 1.25,2)),
    (ROUND(retail * 1.03,2)))"Revised Price"
    FROM books
    ORDER BY category, title;
    But I need something more like this:
    SELECT title "Title", category "Category",retail "Current Price",
    DECODE (ROUND((category,
    'COMPUTER',retail * 1.1,
    'FITNESS', retail * 1.15,
    'SELF HELP', retail * 1.25,
    retail * 1.03)"Revised Price"),2)
    FROM books
    ORDER BY category, title;
    so that ROUND is not repeated more than once..they all need to be rounded to two decimal places.
    any help would be great. Thanks

    your second is close. You need to round the decode statement. like this:
    SELECT title "Title", category "Category",retail "Current Price",
           ROUND(DECODE(category, 'COMPUTER',retail * 1.1,
                                  'FITNESS', retail * 1.15,
                                  'SELF HELP', retail * 1.25,
                                  retail * 1.03),2) "Revised Price"
    FROM books
    ORDER BY category, title;Note that the alias (I assume) revised Proce needs to go outside of both the decode and the round.
    John

  • Help with select function

    Well guys, I have a problem here and I didn't find any solutions
    So maybe someone of you, can help me!
    My problem is:
    I have 2 numbers (100 and -200) and I have to plot the greater value.
    The problem is for me the signal of -(minus) doesn't means nothing....
    For the program I'm making, the -200 is greater than 100
    So I tryed put bouth as absolute value, but when I have the "answer" only appears the "200"
    and I need it appears -200
    So I thought about something like that:
    I use a select function and maybe do something like that:
    So I have to make something at True or False value at S to make this work!
    If true I receive 100, if is false I receive -200
    Thanks!

    I dont know why is in this section. I posted it on LabVIEW part!
    Well Dennis I make it like that:
    But now I have a problem
    I do the same calc for 3 differents variables like A, B, C
    and after that I have to calc which value is the "greater"
    But my problem is, If I have the values "-350 300 -400"
    the greater will be "300" but for me the "minus" don't mean anything
    so I need the greater value is "400"
    For all positive values, its works fine!
    I compare A and B, after that the greater is compared with C and have a result!
    but When I have negative values and positive values... I got that problem...
    and When I have only negative values I have a problem too. 
    "-300 -400 -500" for me the greater value have to be "-500" but labview shows "-300"
    because -300 is greater than -500 in algebriac.
    And If I use absolute values I will always have a positive value... but I need to know if the value is negative or positive
    Anyone, can help me with that?
    Thanks
    Message Edited by EduU on 10-29-2009 11:06 AM

  • Help with select statement

    Hello,
    My table looks similar to this, I have removed a few columns:
    table1:
    Forecast_id Forecast_name Freeze Enabled
    100 Q12009 N Y
    101 Q22009 N Y
    table2:
    forecast_id parameter_name parameter_value
    100 StartDate 01/01/2009
    100 EndDate 03/31/2009
    100 Growth % 20
    100 Retailer Walmart
    101 StartDate 04/01/2009
    101 EndDate 06/30/2009
    101 Growth % 20
    101 Retailer Walmart
    What i need to do is
    select from table 1, forecast name & freeze
    where in table2 parameter = Retailer, Parameter value = Walmart and
    Start Date = 01/01/2009 and End Date = 03/31/2009
    here is my query is there a easy way this can be done. I have used decode function in the past for similar situation for counting and grouping.
    SELECT i.FORECAST_ID,
    i.FORECAST_NAME,
    i.FREEZE_FLAG
    FROM (
    SELECT x.FORECAST_ID,
    x.FORECAST_NAME,
    x.FREEZE_FLAG
    FROM (
    SELECT A.FORECAST_ID,
    A.FORECAST_NAME,
    A.FREEZE_FLAG
    FROM GC_FORECAST A, GC_FORECAST_PARAMETERS B
    WHERE A.FORECAST_ID = B.FORECAST_ID
    AND B.PARAMETER_NAME = 'Retailer'
    AND B.PARAMETER_VALUE = 'Walmart'
    ) x, GC_FORECAST_PARAMETERS y
    WHERE x.FORECAST_ID = y.FORECAST_ID
    AND y.PARAMETER_NAME = 'StartDate'
    AND y.PARAMETER_VALUE = '01/01/2009'
    ) i, GC_FORECAST_PARAMETERS j
    WHERE i.FORECAST_ID = j.FORECAST_ID
    AND j.PARAMETER_NAME = 'EndDate'
    AND j.PARAMETER_VALUE = '03/31/2009';
    Thank you for your time and help.
    Vidhya
    Edited by: snaraya9 on Dec 5, 2008 12:03 PM
    Edited by: snaraya9 on Dec 5, 2008 12:06 PM

    Solution
    SELECT gc_forecast.forecast_id, gc_forecast.forecast_name, gc_forecast.freeze,
           gc_forecast.enabled
      FROM gc_forecast,
           (SELECT   forecast_id,
                     MAX (CASE
                             WHEN parameter_name = 'StartDate'
                             AND parameter_value = '01/01/2009'
                                THEN 1
                             ELSE 0
                          END
                         ) cond1,
                     MAX (CASE
                             WHEN parameter_name = 'EndDate'
                             AND parameter_value = '03/31/2009'
                                THEN 1
                             ELSE 0
                          END
                         ) cond2,
                     MAX (CASE
                             WHEN parameter_name = 'Retailer'
                             AND parameter_value = 'Walmart'
                                THEN 1
                             ELSE 0
                          END
                         ) cond3
                FROM gc_forecast_parameters
            GROUP BY forecast_id) gf
    WHERE gc_forecast.forecast_id = gf.forecast_id
       AND gf.cond1 = 1
       AND gf.cond2 = 1
       AND gf.cond3 = 1
    Demo
    SQL*Plus: Release 10.1.0.4.2 - Production on Ven. Déc. 5 15:34:14 2008
    Copyright (c) 1982, 2005, Oracle.  All rights reserved.
    Connecté à :
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> /* Formatted on 2008/12/05 15:33 (Formatter Plus v4.8.8) */
    SQL> WITH gc_forecast_parameters AS
      2       (SELECT 100 forecast_id, 'StartDate' parameter_name,
      3               '01/01/2009' parameter_value
      4          FROM DUAL
      5        UNION ALL
      6        SELECT 100, 'EndDate', '03/31/2009'
      7          FROM DUAL
      8        UNION ALL
      9        SELECT 100, 'Growth', '% 20'
    10          FROM DUAL
    11        UNION ALL
    12        SELECT 100, 'Retailer', 'Walmart'
    13          FROM DUAL
    14        UNION ALL
    15        SELECT 101, 'StartDate', '04/01/2009'
    16          FROM DUAL
    17        UNION ALL
    18        SELECT 101, 'EndDate', '06/30/2009'
    19          FROM DUAL
    20        UNION ALL
    21        SELECT 101, 'Growth', '% 20'
    22          FROM DUAL
    23        UNION ALL
    24        SELECT 101, 'Retailer', 'Walmart'
    25          FROM DUAL),
    26       gc_forecast AS
    27       (SELECT 100 forecast_id, 'Q12009' forecast_name, 'N' freeze, 'Y' enabled
    28          FROM DUAL
    29        UNION ALL
    30        SELECT 101, 'Q22009', 'N', 'Y'
    31          FROM DUAL)
    32  SELECT gc_forecast.forecast_id, gc_forecast.forecast_name, gc_forecast.freeze,
    33         gc_forecast.enabled
    34    FROM gc_forecast,
    35         (SELECT   forecast_id,
    36                   MAX (CASE
    37                           WHEN parameter_name = 'StartDate'
    38                           AND parameter_value = '01/01/2009'
    39                              THEN 1
    40                           ELSE 0
    41                        END
    42                       ) cond1,
    43                   MAX (CASE
    44                           WHEN parameter_name = 'EndDate'
    45                           AND parameter_value = '03/31/2009'
    46                              THEN 1
    47                           ELSE 0
    48                        END
    49                       ) cond2,
    50                   MAX (CASE
    51                           WHEN parameter_name = 'Retailer'
    52                           AND parameter_value = 'Walmart'
    53                              THEN 1
    54                           ELSE 0
    55                        END
    56                       ) cond3
    57              FROM gc_forecast_parameters
    58          GROUP BY forecast_id) gf
    59   WHERE gc_forecast.forecast_id = gf.forecast_id
    60     AND gf.cond1 = 1
    61     AND gf.cond2 = 1
    62     AND gf.cond3 = 1;
    FORECAST_ID FORECA F E
            100 Q12009 N Y
    SQL>

  • Need help with Telnet command in JSP

    Here is the code I have been working on but it will not display the buffer to the page..
    String [] cmd1 = {"cmd.exe","/c","telnet hqsun1.xx.xxxxx.com"};
              Process n;
              String T = "" ;
              n = Runtime.getRuntime().exec(cmd1);
              BufferedReader in1 =
              new BufferedReader(new InputStreamReader(
              n.getInputStream()));
              while((T=in1.readLine()) != null)
              out.println(T+"");
    Maybe someone has done this before? I am trying to acomplish a telnet net session to the screen with some exicuted commands, because this tool is going to be used to help determine system status when the help desk needs to check on something.
    Thanks

    I don't want to be discouraging, but I'm not quite sure you've thought the problem through. You say that you'd like to create a web page capable of providing various pieces of information to the help desk, and you suggest ping and the output of various canned telnet commands as examples.
    What is preventing the help desk from just executing those commands at the command prompt?
    I realize that the people working the help desk are (ahem) there for a reason, but it is really much faster for me to just simply type "ping www.mpalfrey.com" at the prompt, then it is for me to fire up the web browser and wait for a response that way. You will likewise find that it is a lot more convenient to perform diagnosis on remote machines directly from the command prompt.
    Uh, it's kind of like giving someone a screwdriver, then saying, "oh wait a second" and making them wear an oven mitt in order to use the screwdriver.
    But, if you really want to do it this way, the best thing to do is create a wrapper class that directly calls the system command and captures the output to a stringbuffer. Then your JSP page simply has to clone that wrapper via a new() command and trigger it if you go the singleton route. The code would look something like this...
    <%@ import page="com.mpalfrey.shellcommands.ping" %>
    <%
       myPing foo = new myPing( request.getParameter( "victim" ) );
       foo.trigger();
    %>
    Ping results:
    <%=foo.results()%>JSP can do a lot of wonderful things, but that doesn't mean you have to do it that way. :)

  • Need help with IOS commands to see wireless printer

    Seems that I'm not asking the question correctly, or providing the right information.
    The problem:
    I've purchased a wireless printer, (an HP 6500a) and I can not see / ping / use the printer on the wireless network.
    Environment:
    Cisco 891 ISR in standalone. Single office - Home-office environment. Nothing spectacular. WLAN connected and operational to the internet.
    The printer is configured to use a static IP of 10.0.0.3 and reports that it is connected to the AP. However, when I ping FROM the command line at the AP, I DO NOT see the printer. (I did previously, but we lost power last night due to a storm and I'm still trying to reconfigure it...) DHCP is configured on the router to exclude the range 10.0.0.1 through 10.0.0.99
    How do I configure the wireless router to allow any connected client to share files / printers etc? Seems that the Cisco router has this shut off
    by default and I've found nothing in the user manual or by asking for help on here how to reverse this so that I can share printers / files on the LAN.
    Please, I'm not stupid, but I'm only casually familiar with IOS and Cisco's networking terms.
    Thanks in advance,
    -Mike
    =============== Begin Wiresless AP config (running-config) ==============
    Current configuration : 3122 bytes
    version 12.4
    no service pad
    service timestamps debug datetime msec
    service timestamps log datetime msec
    no service password-encryption
    hostname (Remnoved)
    enable secret 5 (Removed)
    no aaa new-model
    dot11 syslog
    dot11 ssid (Removed)
       vlan 1
       authentication open
       authentication key-management wpa
       mbssid guest-mode
       wpa-psk ascii 0 (Removed)
    username (removed)
    username (Removed)
    bridge irb
    interface Dot11Radio0
    no ip address
    no ip route-cache
    encryption vlan 1 mode ciphers tkip
    broadcast-key vlan 1 change 30
    ssid (Removed)
    antenna gain 0
    station-role root
    interface Dot11Radio0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    bridge-group 1 subscriber-loop-control
    bridge-group 1 block-unknown-source
    no bridge-group 1 source-learning
    no bridge-group 1 unicast-flooding
    bridge-group 1 spanning-disabled
    interface Dot11Radio1
    no ip address
    no ip route-cache
    encryption vlan 1 mode ciphers tkip
    broadcast-key vlan 1 change 30
    ssid (Removed)
    antenna gain 0
    dfs band 3 block
    channel dfs
    station-role root
    interface Dot11Radio1.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    bridge-group 1 subscriber-loop-control
    bridge-group 1 block-unknown-source
    no bridge-group 1 source-learning
    no bridge-group 1 unicast-flooding
    bridge-group 1 spanning-disabled
    interface GigabitEthernet0
    description the embedded AP GigabitEthernet 0 is an internal interface connecting AP with the host router
    no ip address
    no ip route-cache
    interface GigabitEthernet0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    no bridge-group 1 source-learning
    bridge-group 1 spanning-disabled
    interface BVI1
    ip address dhcp client-id GigabitEthernet0
    no ip route-cache
    ip http server
    no ip http secure-server
    ip http help-path http://www.cisco.com/warp/public/779/smbiz/prodconfig/help/eag
    access-list 110 permit icmp any any echo
    access-list 110 permit icmp any any echo-reply
    access-list 110 permit icmp any any source-quench
    access-list 110 permit icmp any any packet-too-big
    access-list 110 permit icmp any any time-exceeded
    bridge 1 route ip
    banner login ^CC
    % Password change notice.
    Default username/password setup on AP is cisco/cisco with privilege level 15.
    It is strongly suggested that you create a new username with privilege level
    15 using the following command for console security.
    username <myuser> privilege 15 secret 0 <mypassword>
    no username cisco
    Replace <myuser> and <mypassword> with the username and password you want to
    use. After you change your username/password you can turn off this message
    by configuring  "no banner login" and "no banner exec" in privileged mode.
    ^C
    line con 0
    privilege level 15
    login local
    no activation-character
    line vty 0 4
    login local
    cns dhcp
    end

    Wireless clients can get on w/o issue. Nobody can ping anyone else or see them.
    No file sharing, no printer.
    Tried using the web-based config which works for some items, but wont access the advanced config.
    I'm on my way into town, so can't post the router config, but it is posted in my earlier question
    of last week. I can login later if you otherwise need it here.
    Thanks,
    -Mike

Maybe you are looking for

  • How can I find out the semester in a date?

    Hello I have this query SELECT 1949+rowno_year || lpad(rowno_month, 2, '0') MONTH_ID, to_char(to_date(to_char(1949+rowno_year || lpad(rowno_month, 2, '0')),'YYYYMM' ),'MONTH','NLS_DATE_LANGUAGE = ENGLISH') MONTH_NAME, to_char(to_date(to_char(1949+row

  • ITunes is no longer listed in Default Programs in Vista

    After accepting the latest update to iTunes (7.6.029) + QuickTime this afternoon, there are several registry keys associated with iTunes and QuickTime that no longer have the appropriate permissions set which I believe is the main reason why iTunes i

  • Host Command Problems on 9i Unix

    I am using web froms 9i running on a Unix server with 9iasr2. I am trying to manipulate files on the server not the client. I have tried: host('rm -f /mypath/filename.txt') host('rm -f /mypath/filename.txt',NO_SCREEN) host('touch /mypath/filename.txt

  • Compatibility fcpx 10.2.1 / fcpx 10.1.1

    Hi, I'm just starting out with tcp and have been practicing on the trial version of fcpx 10.2.1 which is going to run out in 2 days.  I now have to complete what I was doing on another computer which has fcpx 10.1.1.  I can't open the project and whe

  • Office 365 Settings

    I have just received my Sony Xperia Z  Tablet. I have been trying for hours to get it to sync with my Office 365 account but can not get it to sync. I have lauched the email accounts on my Sony Created a new "Exchange Account" Put in my Email address