Sql calculation help needed.

Hi all gurus.
I'm having problem where I need to calculate AR days.
formula  is (sales of prior 3 months/90)/Ar $ amount.= Days
Data is stored in two different table.
1.Monthly data table .
CURR_MO                 REVENUE_PRIOR_MO (in Sept they will enter what was made/achieved in AUG)
JANUARY                                 0
FEBRUARY                          1717631
MARCH                             1591972
APRIL                             1649450
MAY                               1662600
JUNE                              1667823
JULY                              1669651
AUGUST                         1709323
SEPTEMBER                   2006983
2) Ar $ value enter each week  in Balance sheet table
AR$            week#   period
2589570
10
07-MAR-13
2376294
11
14-MAR-13
2454919
12
22-MAR-13
2767058
13
31-MAR-13
2603831
14
05-APR-13
2759590
15
11-APR-13
2376294
16
18-APR-13
2308476
17
26-APR-13
2455142
18
02-MAY-13
2498546
19
10-MAY-13
2457499
21
23-MAY-13
2461661.79
22
30-MAY-13
2310346
23
06-JUN-13
2512139
24
13-JUN-13
2267758
25
20-JUN-13
2497566
26
27-JUN-13
2583208
27
04-JUL-13
2195667
28
11-JUL-13
2288098
29
18-JUL-13
2322778
30
25-JUL-13
2306878
31
01-AUG-13
2513741
32
08-AUG-13
2350728
33
15-AUG-13
2554842
34
22-AUG-13
2664116
35
29-AUG-13
2743931
36
05-SEP-13
2501886
37
12-SEP-13
2315477
38
19-SEP-13
I want to take sum of 3 months corresponding
Daily Rev.
June
July
Aug
3-mo Total
     59,844
      1,669,651
      1,709,323
      2,006,983
      5,385,957
Daily Rev.
May
June
July
3-mo Total
      56,076
      1,667,823
      1,669,651
      1,709,323
      5,046,797
Daily Rev.
April
May
June
3-mo Total
      55,556
      1,662,600
      1,667,823
      1,669,651
      5,000,074
Daily Rev.
March
April
May
3-mo Total
      55,332
      1,649,450
      1,662,600
      1,667,823
      4,979,873
Daily Rev.
Feb.
March
April
3-mo Total
      54,489
      1,591,972
      1,649,450
      1,662,600
      4,904,022
Daily Rev.
Jan
Feb.
March
3-mo Total
      55,101
      1,717,631
      1,591,972
      1,649,450
      4,959,053
Highlighted daily values with be divided by Ar $ amount  depending on monthly daily rev.
Output should be like (roughly this not actually output)
ARDAYS
WEEK_NUMBER
          47
10
          43
11
          45
12
          50
13
          48
14
          51
15
          44
16
          42
17
          44
18
          45
19
          44
21
          44
22
          42
23
          45
24
          41
25
          45
26
          46
27
          39
28
          41
29
          41
30
          39
31
          42
32
          39
33
          43
34
          45
35
          46
36
          42
37
          39
38

I got the answer
"use the latest 3 completed months for each week"
as soon sliding window hit JUNE use june (apr-may-june)value to divide
output (coulm 1 and 2 only)
ARDAYS
WEEK#
period
AR $
          47
10
3/7/2013
2589570
          43
11
3/14/2013
2376294
Daily Rev.
June
July
Aug
3-mo Total
          45
12
3/22/2013
2454919
      59,844
      1,669,651
      1,709,323
      2,006,983
      5,385,957
          50
13
3/31/2013
2767058
          48
14
4/5/2013
2603831
Daily Rev.
May
June
July
3-mo Total
          51
15
4/11/2013
2759590
      56,076
      1,667,823
      1,669,651
      1,709,323
      5,046,797
          44
16
4/18/2013
2376294
          42
17
4/26/2013
2308476
Daily Rev.
April
May
June
3-mo Total
          44
18
5/2/2013
2455142
      55,556
      1,662,600
      1,667,823
      1,669,651
      5,000,074
          45
19
5/10/2013
2498546
          44
21
5/23/2013
2457499
Daily Rev.
March
April
May
3-mo Total
          44
22
5/30/2013
2461662
      55,332
      1,649,450
      1,662,600
      1,667,823
      4,979,873
          42
23
6/6/2013
2310346
          45
24
6/13/2013
2512139
Daily Rev.
Feb.
March
April
3-mo Total
          41
25
6/20/2013

Similar Messages

  • SQL Server2008 help needed

    Having trouble with SQLServer 2008 (not MySQL) and my database connection in Dreamweaver CS6.  My document type is set as .asp using VBScript.  I can list the table information  but cannot use the insert wizard to add new records.  I don't get any errors after creating the insert form, but no records get inserted.  I'm not a VBScript expert, but do I have to manually write some code to insert records?  How do I attach it to a button?

    Thanks for the quick reply.  I won't be back in the office for a few days, but I'll try to post it when I get back in.  It's pretty much the code generated from the Dreamweaver Insert Record wizard.  I see where the submit button is created and the value is set but the action on the form is set to MM_insert, so I don't see where the submit code is actually called.
    Date: Wed, 3 Oct 2012 12:06:14 -0600
    From: [email protected]
    To: [email protected]
    Subject: SQL Server2008 help needed
        Re: SQL Server2008 help needed
        created by bregent in Dreamweaver General - View the full discussion
    This post should be moved to the app dev forum.  Please post the code from your form and the insert script pages.
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4746757#4746757
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4746757#4746757
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4746757#4746757. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver General by email or at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • SQL Report help needed

    Hi All,
    I am creating a report which is having 2 sql queries ,1 for the main columns that i need to show and 2 from total sum and count.
    Report is something as given below
    SET TAB OFF;
    set linesize 1500;
    set pagesize 50;
    SET FEEDBACK OFF;
    SET WRAP OFF
    COLUMN today NEW_VALUE VAR1 NOPRINT;
    TTITLE LEFT 'ABC Inc.' SKIP 1 -
    LEFT 'Daily Report' SKIP 1 -
    LEFT 'As Of ' VAR1 SKIP 2
    BTITLE LEFT SKIP 'Page No : ' FORMAT 9999999999 SQL.PNO SKIP 3;
    COL SR_NO HEADING 'Seq'               FORMAT 999999;
    COL REFNO HEADING 'Ref No'                FORMAT A20;
    COL ORIG_NAME HEADING ' Branch Name'      
         FORMAT A50;
    SELECT      ROWNUM                SR_NO,
         REF_NO                REFNO,
         ORIGIN_NAME               BRNAME
    FROM BANK
    WHERE PASS_CD=101
    SELECT      ' Failure Count : '|| NVL(COUNT(DECODE(CODE,1,CODE,NULL)),0) ||
         ' Failure Total Amt : '|| NVL(SUM(DECODE(CODE,799,AMT,NULL)),0)
         || CHR(10) ||     
         ' Successful Count : '|| NVL(COUNT(DECODE(CODE,000,CODE,NULL)),0) ||
    ' Successful Total Amt: '|| NVL(SUM(DECODE(CODE,000,AMT,NULL)),0)
    FROM BANK;
    CLEAR BREAKS;
    CLEAR COLUMN;
    TTITLE OFF;
    When i am running this second query output is going to secong page and title is repeated again and same as 1rst page is showing page no-1
    Kindly help me,i want the output on the same page at bottom.
    Thanks

    i think its only work in ISQL* PLUS enivironment iam
    not sure.It does work in SQL*Plus
    is that i can use in the package??http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14357/ch12048.htm

  • PDF form field calculation help needed

    I need to make some simple calculations on a pdf form and need some help.
    I have a form field for number of guests.
    A field for a set cost for various tickets (there are 3 levels of ticket prices) (I might not need this field).
    A subtotal of the guests attending and ticket price.
    A grand total of the subtotals.
    I can't figure out how to either put in a fixed cost in a form field or input a calculation so that the number of tickets is muliplied by a fixed number and gives me a subtotal.
    Thanks.

    Ok. I finally got the calculations to work. But..... when I save and open in Reader, they don't work. Go back to Pro, they don't work there now either. They also don't show up under the Set Field Order Calculations. To reset them, i have to erase the calculations, save, redo the calculations. Preview the form and everything works — calculations happen and i get a total.
    Adobe Reader usage rights are enabled.
    Why is this so hard?
    I found this thread http://forums.adobe.com/message/1152890#1152890 about it. Is this bug still going on since 2009?
    Ok. Apparently you have to enable reader rights after the form is done. It seems to work now. What a pain.

  • Oracle 11G Install on Win 7 With PL/SQL Developer Help Needed

    Today is my first day with Oracle. I have tried to Install Ora11g from our network drive.I think the installation went fine. I also installated PL/SQL Developer when i try to log in i got the following error see below.
    PL/SQL Developer - (Not logged on)
    Initialization error
    SQL*Net not properly installed
    OracleHomeKey: SOFTWARE\ORACLE
    OracleHomeDir:
    OK
    After i did some research online i found this solution "go to Tools > Preferences > options set manually "Oracle Home" to the folder of ORACLE_HOME and "OCI Library" to the oci.dll file located in ORACLE_HOME/bin/oci.dll"
    C:\app\user\product\11.2.0\client_1\bin.dll <=== I believe this is my Oracle_Home
    C:\app\user\product\11.2.0\client_1\bin\oci.dll <==== Is my OCI Library.
    When i apply thse 2 paths i get the following error.
    Initialization error
    COuld not load " C:\app\user\product\11.2.0\client_1\bin.dll
    OCIDLL forced to C:\app\user\product\11.2.0\client_1\bin.dll
    LoadLibrary(C:\app\user\product\11.2.0\client_1\bin\.dll)returned 0
    Can someone help me with this ???????????????/

    Pl indicate which version of Win 7 - you will need Professional or higher - Home versions are not supported/certified, so things may or may not work as expected.
    http://download.oracle.com/docs/cd/E11882_01/install.112/e16773/reqs.htm#CHDHGGFE
    HTH
    Srini

  • How to optimize this SQL. Help needed.

    Hi All,
    Can you please help with this SQL:
    SELECT /*+ INDEX(zl1 zipcode_lat1) */
    zl2.zipcode as zipcode,l.location_id as location_id,
    sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2)) as distance
    FROM location_atao l, zipcode_atao zl1, client c, zipcode_atao zl2
    WHERE zl1.zipcode = l.zipcode
    AND l.client_id = c.client_id
    AND c.client_id = 306363
    And l.appType = 'HOURLY'
    and c.milessearchzipcode >= sqrt(POWER((69.1 * ((zl2.latitude*57.295779513082320876798154814105) - (zl1.latitude*57.295779513082320876798154814105))),2) + POWER((69.1 * ((zl2.longitude*57.295779513082320876798154814105) - (zl1.longitude*57.295779513082320876798154814105)) * cos((zl1.latitude*57.295779513082320876798154814105)/57.3)),2))
    I tried to optimize it by adding country column in zipcode_atao table. So that we can limit the search in zipcode_atao table based on country.
    Any other suggestions.
    Thanks

    Welcome to the forum.
    Please follow the instructions given in this thread:
    How to post a SQL statement tuning request
    HOW TO: Post a SQL statement tuning request - template posting
    and add the nessecary details we need to your thread.
    Depending on your database version (the result of: select * from v$version; ):
    Have you tried running the query without the index-hint?
    Are your table (and index) statatistics up-to-date?

  • Calculations Help Needed

    Here is the situation:
    I am doing a quick "play around" between Pages/Word, Numbers/Excel and Keynote/Powerpoint.
    This is to refresh my memory to windows, since I am going into a short-term (5 - 7 or 8 years) of IT.
    I need help with calculating the average time of sunrise for one week, using two sheets.
    The times given are 5:40am, 5:41am, ........ 5:46am. The cells: B5 - B11 (Sunrise Column for week 1). The name for this sheet is "Weekly".
    The equation is going to be place in cell B5 of sheet named "Monthly" representing the average time of sunrise for that week.
    In excell, I understand "Weekly!B3" refers to cell B3 on worksheet "Weekly".
    How would I do this in numbers? (I will figure out how to do it in Excell.)
    Thanks again guys (and ladies)!

    In fact, the problem is not the one which you described.
    The way to reference a cell or a range of cell is perfectly described in iWork Formula and Functions User Guide in which every user may get it.
    The important thing to know is that in NumbersLand, 5:40am isn't a time value but a date_time one.
    In the tables above, I deliberately choose to insert time values entered at different dates so, the formula inserted in Monthly :: B5
    =AVERAGE(Weekly :: B5:B11)
    return an exact result which doesn't match what we are wanting to get.
    This is why I used the auxiliary column C
    In Weekly :: C5, the formula is :
    =TIMEVALUE(B)
    Apply Fill Down to insert the formula in rows below.
    The formula returns the time value using the unit day.
    In Monthly // C5, the formula is :
    =AVERAGE(Weekly :: C5:C11)
    but I guess that you don't wish to get the result in this format.
    In Monthly // D5, the formula is :
    =DURATION(0,AVERAGE(Weekly :: C5:C11))
    You may edit the format of this duration cell as you want.
    An alternate formula would be :
    =TIME(,AVERAGE(Weekly :: C5:C11)*24*60,)
    But CAUTION, one more time, as you may see, the cell will contain a date component.
    Yvan KOENIG (VALLAURIS, France) vendredi 27 mai 2011 12:20:15
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.7
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Sql loader help needed  urgent

    Hi,
    I normally get a csv having data as
    column1 ;columnb;columnc;
    13 ; 12 ; 13 ;
    11 ;13 ;33;
    as the table where it needs to go is say table
    xys( a number, b number , c number).
    so the control file is fairly simple ...
    But from now I need to restrict data entry if the change in format happens in the csv
    say if it is like
    column2;column1;column3,
    12,13;12;
    11;13;14;
    or say the csv like
    column1;column2;column3;column4;
    11;13;14;15;
    111;134;14;12;
    in both cases sql loader should not run and throw the error saying the reason in the log.
    how do i manage it in the control file `???
    any ideas???
    regards
    Message was edited by:
    SHUBH

    Hello,
    do you only need to check the first line of the file if it contains a line like
    column1;column2;column3 ?
    If yes, maybe a small script like this could be a starting point:
    You have to replace "column1;column2;column3" with the header information that's valid and instead of file1 in the CURRENTSTRING=... Line write the name of your input file.
    I hope this helps. (But maybe some of the experts here knows a way to do the verification checks with SQLLDR, so maybe its worth to wait a little bit :)
    #!/bin/ksh
    VALIDSTRING="column1;column2;column3"
    CURRENTSTRING=`head -n 1 file1`
    if [[ $VALIDSTRING == $CURRENTSTRING ]]
    then
    echo "They match."
    else
    echo "They dont match."
    fi
    --

  • REPORT CALCULATION HELP NEEDED!!!

    Hello
    I have a report where i need to do some calculation .
    I have 3 columns in my report Businesstype , Business Code & Fact . When i display the report i see the Business Code 1 - Business Code 5 in 5 rows . But sometimes the report contains Business Code 6 along with Business Code 1 - Business Code 5 then Business Code 6 needs to calculate SUM(Business Code 1-6) and display in one row .
    Could anybody please leave me any suggestions .

    Hi there,
    Create a table
    - On the first row create for each group to populate the data for Business Code [1-n] with a second column containing numeric values.
    - On the second row use the sum function using current-group() function for the value that you want to calculate the sum for.
    Hope this helps.
    Let me how you get on.
    cheers...

  • SQL problem - help needed ASAP!!

    Hey guys,
    Doing a college project... would really appreciate some help. I am trying to use a variable in the where clause of a select cursor in PL/SQL. The code is this:
    procedure results(p_search_entry varchar2, p_search_field varchar2) is
    cursor c_results is
    select * from physics_b where p_search_field = p_search_entry;
    begin
    for cv_results in c_results
    loop
    -- loop through actions
    end loop;
    The problem is that I don't know how to get the where clause to accept the variable passed into the procedure as the field name. Does anyone know the syntax for this?
    Thanks very much!
    Niall

    This isn't the correct forum for this kind of question. The SQL and PL/SQL forum PL/SQL is probably best.
    That said, you can't do what you want that way.
    You can do
    procedure results (p_search_entry in varchar2)
    cursor c_result is
    select * fro physics_b where subject=p_search_entry;(assuming subject is a column in physics_b)
    You can't use a variable to represent a column directly. You need to build the statement as a string and then use execute immediate.
    statement:='select * fro physics_b where '||p_search_field||' = :1';
    -- this bit is probably bad syntax.
    execute immediate statement using p_search_entry;Look up execute immediate and bind variables

  • SQL Syntax - help needed

    Guys,
    Help me understand the syntax please!! With PL/SQL I have achieved a task quite easily, with a branch of code to include or exclude some part of the query - no problem. But to use SQL ......
    If i have a variable on a page, say :p10_open_or_closed
    .. and I set the value of this to the text "Is Not Null"
    How can I incorporate this into an SQL query, say
    Select ID, Date1, Date2, Comment
    From Table1
    where Date1 Is Not Null
    Is there a way of substituting the ":p10_open_or_closed" variable into this query?
    ie
    Select ID, Date1, Date2, Comment
    From Table1
    where Date1 ":p10_open_or_closed"
    Thanks.

    Thanks for your help gents.
    Originally, I had a PL/SQL Statement constructing the code as needed, as Rekha
    suggested.
    if :P1_OPEN_OR_CLOSED = 1 then
    q:=q||' and ';
    q:=q||' p.ACTUAL_INSTALL_DATE is null ';
    end if;
    if :P1_OPEN_OR_CLOSED = 2 then
    q:=q||' and ';
    q:=q||' p.ACTUAL_INSTALL_DATE is not null ';
    end if;
    But, to use a Tabular form, where users can update fields of multiple records on screen then submit for a MRU, the option of PL/SQL code is not allowed, only SQL. So Phil UK, no it's not an elegant way of doing things, but I'm forced to use SQL, yeah?
    There are definitely ways that I can filter for the solution I am after, but they all involve more in depth solutions (that are not that great). Thus, I asked at this forum.
    Andy, your solution works :~) which makes me very happy. I'm not sure how just now but I'll learn from it.
    Thanks again.

  • SQL Filter Help Needed

    Hello,
    I am in need of some SQL help as I am not sure how to do it.  I want to only return rows of data that meet the following criteria:
    1) in tableA columnA it could have a value shown as such:  A,B,1,2,3,5,8
    2) in tableA columnB it shows one of the following four variables (Test1, Test2, Test3, Test4)
    3) in tableA columnC it will show a date.
    4) in tableB there is a row for each day of the year. 
    5) in tableB there is a column that matches each of the four variables in #2 above. 
    First it should match the date in tableA ColumnC to the row in tableB that matches.  Then it should then find the column in tableB that matches to the value in tableA columnB.  in that cell it will have a single value from A-D or 1-9.  If it is an A for example, it will need to check against tableA columnA.  if it has an A in it, it will return it.  If it does not, it will not.  
    Does anyone have any idea how to write this?  Is this possible?
    Thank you,
    Jeff

    Check the query using hardcoded values first - values taken from your explication
    select x.idfield
      from tablea x,
           (select datedefinefield,
                   'VARIABLE4' the_variable,
                   case 'VARIABLE4' when 'VARIABLE1'
                                      then variable1
                                      when 'VARIABLE2'
                                      then variable2
                                      when 'VARIABLE3'
                                      then variable3
                                      when 'VARIABLE4'
                                      then variable4
                   end the_value
              from tableb
             where datedefinefield = date '2013-01-01'
           ) y
    where x.datefield = y.datedefinefield
       and x.variablefield = y.the_variable
       and instr(','||x.codefield||',',','||y.the_value||',') > 0
    then replace the hardcoded values with bind variables
    select x.idfield
      from tablea x,
           (select datedefinefield,
                   :the_variable the_variable,
                   case :the_variable when 'VARIABLE1'
                                      then variable1
                                      when 'VARIABLE2'
                                      then variable2
                                      when 'VARIABLE3'
                                      then variable3
                                      when 'VARIABLE4'
                                      then variable4
                   end the_value
              from tableb
             where datedefinefield = to_date(:the_date,'yyyymmdd')
           ) y
    where x.datefield = y.datedefinefield
       and x.variablefield = y.the_variable
       and instr(','||x.codefield||',',','||y.the_value||',') > 0
    type the values in the window SQL Developer displays before execution to prompt you for bind variable values
    VARIABLE4 for the_variable
    20130101 for the_date
    no quotes this time then hit the Apply ( not very sure that's the caption) button to start execution and you should get the same result as with hardcoded values.
    If that works, you can start playing with (submitting values of your choice)
    Regards
    Etbin

  • SQL queries help need-urgent

    Based on your inputs-I studied and created the below objects.I apologise for asking lengthy questions,but i
    need your help very much now to proceed next.
    There is a COMPANY WHICH has many divisions/departments in it.
    These divisions has employees.
    *{color:#0000ff}--Created employee table which employee_id and Salary.*
    **employees (*empid,salary){color}*
    *{color:#0000ff}***DO i need to put the DEPT_ID and Manager_id in the EMPLOYEES table? {color}*
    *{color:#0000ff}--Presently,iCreated a relationship table to have EMPLOYEE"S MANAGER information.a manager is an employee itself.{color}*
    *{color:#0000ff}--Created a table for EMPLOyee and department---RELATIONSHIP ---&gt; empl_id and dept_id{color}*
    The COMPANY has numerous Products(also we can say projects) and these project work is done by the various depts.
    *{color:#0000ff}Projects /Job table*
    *--job_id*
    *--Project_name*
    *--Budget Amount{color}*
    *{color:#0000ff}--Created a table for Project and department---RELATIONSHIP ---&gt; proj_id and dept_id*
    *--Also,Created a table for Project and Employee---RELATIONSHIP ---&gt; proj_id and employee_id{color}*
    Also,here scenario (1)Employees can work or be a part of many or multiple departments and work for multiple projects/products at a time (2)As usual-each Department has a manager.**EVery dept can handle or work only on one project.
    *{color:#0000ff}--Created a table for Project and department---RELATIONSHIP ---&gt; proj_id and dept_id*
    *--Also,Created a table for Project and Employee---RELATIONSHIP ---&gt; proj_id and employee_id*
    *{color}*
    _*{color:#000000}***(1)Are the tables and the relationships defined above enough or have i created too much tables?Please advise me.{color}*_
    Queries:-Need to write SQLs for below items.Please help me.Could you all have a look
    bq. h5. {color:#0000ff} \\ _     (2)SQL for a person see all his manager?***A person can have 2,3 managers._ \\ _     (3)need a person---&gt;manager--&gt;and their manager's MANAGER_ \\ _     (4)How will managers to view all employees reporting to him._ \\ {color} \\ h5. \\ {color:#0000ff}_(5)feasibility (SQL) to support the increase of salaries of employees in a department by percentage or amount wise._ \\ _     (6)SQL to update or change manager of a department/employee._ \\ {color} \\ h5. \\ {color:#0000ff}_(7)If a employee is removed-then all related details should also be removed._ \\ _     (8)to remove person and department,terminate a person from organisation_ \\ _     SHIFTING a person to different department,assign a person to a department_{color} \\ h5. {color:#0000ff}_SQL to collect all info of a person, his managers , departments and project this employee works._ \\ _     find Department which dont have managers._{color} \\ h5. \\ {color:#0000ff}_****find expenditure all projects together in terms of salary_{color}

    Sorry for all the confusion with the questions.So let me clear myself,i am doing this not as assignment or homework,but something
    which interests me and trying to leran.Earlier as I stated that its a part of my school(** well frnakly speaking, it was my plan if i could
    put this as an item of the school as the scope is very huge.
    *(1)one employee can be in many departments(1 TO MANY) and and each department has one manager.(1 to 1)*
    Created a table for EMPLOyee and department-RELATIONSHIP ---&gt; empl_id and dept_id*
    (2)Also,an employee can work in multiple items/projects(1-MANY) at a time. And a project HAS only one department.(1 to 1)
    **Projects table created has codes,the Project name ,Planned budget cost/amount, start_date and end_date AND DEPART_ID
    Also,Created a table for Project and Employee-RELATIONSHIP ---&gt; proj_id and employee_id*
    This is the full scenario has put above.So,i needed help as I am very confused if i have done the correct relationships.
    And,these below items are my plans to allow the schema nd tables support it.
    (2)how will a person see all his manager?***A person can have 2,3 managers.(EMP-&gt;MANAGER relationship TABLE)
    (3)SQL to be able to show a person---&gt;manager--&gt;and their manager's MANAGER
    (4)How will managers to view all employees reporting to him.
    (5)SQL to support the increase of salaries of employees in a department by percentage or amount wise.
    (6)SQL to update or change manager of a department/employee.
    (7)If a employee is removed-then all related details should also be removed.
    (8)to remove person and department,terminate a person from organisation
    SHIFTING a person to different department,assign a person to a department
    Projects /Job table EMPLOYEES TABLE-&gt; SALARY info
    --job_id
    --Project_name
    --Budget Amount

  • SQL Query Help Needed

    I'm having trouble with an SQL query. I've created a simple logon page wherein a user will enter their user name and password. The program will look in an Access database for the user name, sort it by Date/Time modified, and check to see if their password matches the most recent password. Unfortunately, the query returns no results. I'm absolutely certain that I'm doing the query correctly (I've imported it directly from my old VB6 code). Something simple is eluding me. Any help would be appreciated.
    private void LogOn() {
    //make sure that the user name/password is valid, then load the main menu
    try {
    //open the database connection
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:LawOffice2000", "", "");
    Statement select = con.createStatement();
    String strTemp = "Select * From EMPLOYEES Where INITIALS = '" + txtUserName.getText() + "' Order By DATE Desc, TIME Desc";
    ResultSet result = select.executeQuery(strTemp);
    while(result.next()) {
    if (txtPassword.getPassword().toString() == result.getString("Password")) {
    MenuMain.main();
    else {
    System.out.println("Password Bad");
    System.out.println(txtUserName.getText());
    System.out.println(result.getString("Password"));
    break; //exit loop
    //close the connection
    con.close(); }
    catch (Exception e) {
    System.out.println("LawOfficeSuite_LogOn: " + e);
    return; }
    }

    The problem is here: "txtPassword.getPassword().toString() == result.getString("Password"))"
    Don't confuse String's equals() method with the equality operator '=='. The == operator checks that two references refer to the same object. If you want to compare the contents of Strings (whether two strings contain the same characters), use equals(), e.g. if (str1.equals(str2))...
    Example:String s1 = "foo";
    String s2 = new String("foo");
    System.out.println("s1 == s2: " + (s1 == s2)); // false
    System.out.println("s1.equals(s2): " + (s1.equals(s2))); // trueFor more information, check out Comparison operators: equals() versus ==

  • SQL statement help needed

    I am sure some of you will laugh lol, but I am drawing a blank and need some assistance if anyone is willing to help:
    I have this query:
    SELECT DISTINCT ID
    FROM (SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export) a,
    sforce_product2
    WHERE a.productcode = sforce_product2.productcode
    which returns 112 ID's (which is wrong)
    The inner SELECT statement:
    SELECT productcode
    FROM sforce_product2
    WHERE productcode NOT LIKE 'DSXXX%'
    AND productcode NOT LIKE 'DO NOT USE%'
    AND productcode NOT LIKE 'MAXXXX%'
    AND isactive = 'true'
    MINUS
    SELECT productcode
    FROM vew_product_export
    returns 106.
    Am I doing something simple wrong or is my query just mangled!
    TIA,
    Mike

      SELECT DISTINCT ID
        FROM (SELECT productcode
                FROM sforce_product2
               WHERE productcode NOT LIKE 'DSXXX%'
                 AND productcode NOT LIKE 'DO NOT USE%'
                 AND productcode NOT LIKE 'MAXXXX%'
                 AND isactive = 'true'
              MINUS
              SELECT productcode
                FROM vew_product_export) a,
              sforce_product2
       WHERE a.productcode = sforce_product2.productcodethe above code is returning an ID column which i think most probable from the sforce_product2 table
    while this query below returns the 106 value that is coming from the column productcode.
      SELECT productcode
        FROM sforce_product2
       WHERE productcode NOT LIKE 'DSXXX%'
         AND productcode NOT LIKE 'DO NOT USE%'
         AND productcode NOT LIKE 'MAXXXX%'
         AND isactive = 'true'
      MINUS
      SELECT productcode
        FROM vew_product_exportso i think there is nothing wrong because if you will review the 112 is from the column ID while the 106 is from the column productcode.

Maybe you are looking for

  • Invoking a URL from BPEL PM

    Hi, I need to invoke a URL from a bpel process. what is the best way to do that? i would like to send the URL as is and not build it in the process thanks amit

  • How to deal with--errors occurred, no packages were upgraded

    This has only occurred to me once before, I think. I was running a pacman -Syu today and it was trying to upgrade kernel2612-cko2-swsusp2 with the new kernel26cko package. The old cko was installed by grabbing the pkgbuild, making and then installing

  • Need to generate a script which will sends an email to users reg cube statu

    Hi All, Once the cube gets loaded successfully an email has to sent out automatically thru maxl to users saying that cubes has loaded as off today's date. Could you please help me is their any script available which will automatically sends an email

  • MDX all descendants of member parent

    I need to get all descendants the user belongs to. assuming the user in in group "SalesTeamLead" I then need all the descendants of the group the user is part of. so I think about it like that Ancestors(Head(Filter([DIM_SALES].AllMembers,[DIM_SALES].

  • Same applets running on 2 different browser independent of  each other

    Hi all, I am calling the same applet two times in a browser. So i declared all the variables to be shared by the 2 applets as "private static". Now i want the applets in 1 browser to be independent of the applets in another browser when multiple brow