Help, had fights with this sql for a day now

Grateful if someone could give me a pointer here. fighting with this thing for a day and can't do things.

Have 2 tables
tbl_ate_jun & tbl_pd_jun
the two paintings by xt

This is creates it for everyone.
CREATE TABLE "ME"."TBL_PD_JUN"
  (
    "ID"                  VARCHAR2(500 BYTE),
    "PROJECT_NUMBER"      VARCHAR2(500 BYTE),
    "PROJECT_NAME"        VARCHAR2(500 BYTE),
    "DESCRIPTION"         VARCHAR2(500 BYTE),
    "PROJECT_TYPE"        VARCHAR2(500 BYTE),
    "ORGANIZATIONAL_NAME" VARCHAR2(500 BYTE),
    "CUSTOMER_NAME"       VARCHAR2(500 BYTE),
    "OFFICE_FSR"          VARCHAR2(500 BYTE),
    "PROGRAMS_FSR"        VARCHAR2(500 BYTE)
  )
  ORGANIZATION EXTERNAL
  (
    TYPE ORACLE_LOADER DEFAULT DIRECTORY "XE_FTP" ACCESS PARAMETERS ( records delimited BY newline skip 0 fields terminated BY ',' OPTIONALLY ENCLOSED BY '"' MISSING FIELD VALUES ARE NULL ) LOCATION ( 'tbl_pd_jun.csv' )
  ) ;
CREATE TABLE "ME"."TBL_ATE_JUN"
  (
    "ID"                        VARCHAR2(500 BYTE),
    "PERSON_SSO"                VARCHAR2(500 BYTE),
    "FIRST_NAME"                VARCHAR2(500 BYTE),
    "LAST_NAME"                 VARCHAR2(500 BYTE),
    "VOUCHER_HOURS"             VARCHAR2(500 BYTE),
    "FISCAL_YEAR_WEEK"          VARCHAR2(500 BYTE),
    "ORG_TIER2_NAME"            VARCHAR2(500 BYTE),
    "ORG_TIER3_NAME"            VARCHAR2(500 BYTE),
    "VOUCHER_REASON"            VARCHAR2(500 BYTE),
    "VOUCHERING_STATUS"         VARCHAR2(500 BYTE),
    "ORG_TIER4_NAME"            VARCHAR2(500 BYTE),
    "TIER4_MANAGER_NAME"        VARCHAR2(500 BYTE),
    "VOUCHER_CODE"              VARCHAR2(500 BYTE),
    "VOUCHER_DESCRIPTION"       VARCHAR2(500 BYTE),
    "PERSON_COUNT"              VARCHAR2(500 BYTE),
    "HOUR_TYPE"                 VARCHAR2(500 BYTE),
    "APPLIED_FLAG"              VARCHAR2(500 BYTE),
    "COST_CENTER_CODE"          VARCHAR2(500 BYTE),
    "VOUCHER_CLASS"             VARCHAR2(500 BYTE),
    "VOUCHER_CLASS_DESCRIPTION" VARCHAR2(500 BYTE),
    "VOUCHER_SUB_CLASS"         VARCHAR2(500 BYTE),
    "PROGRAM_TYPE"              VARCHAR2(500 BYTE),
    "PAYCODE_NAME"              VARCHAR2(500 BYTE),
    "PAY_CODE"                  VARCHAR2(500 BYTE)
  )
  ORGANIZATION EXTERNAL
  (
    TYPE ORACLE_LOADER DEFAULT DIRECTORY "XE_FTP" ACCESS PARAMETERS ( records delimited BY newline skip 0 fields terminated BY ',' OPTIONALLY ENCLOSED BY '"' MISSING FIELD VALUES ARE NULL ) LOCATION ( 'tbl_ate_jun.csv' )
  ) ;
Basically, in tbl_ate_jun, it has all the user ID (person_sso)
Im trying to generate a report that contains all person_sso numbers in the first column.
Second column have applied_hours, then office_hours, then programs_hours, then total_hours, then diff_hours (difference).

Here's the code so far, but I just cant get, it is true, that it shows never all of the sso, each select individually works very well, but may not be combined, does not work well.

select a.person_sso,NVL(sum(b.applied_hours),0),NVL(sum(c.office_hours),0),NVL(sum(d.programs_hours),0),NVL(sum(e.total_hours),0),NVL(sum(f.diff_hours),0) 
from 

tbl_ate_jun a,

(SELECT
tbl_ate_jun.person_sso as applied_sso,
tbl_ate_jun.Voucher_Hours as applied_hours
FROM
tbl_pd_jun,
tbl_ate_jun 
WHERE
tbl_ate_jun.voucher_code IN (select project_number from tbl_pd_jun
where Office_FSR IS NULL AND Programs_FSR IS NULL)
and tbl_ate_jun.voucher_code=tbl_pd_jun.project_number
)b,


(SELECT
tbl_ate_jun.person_sso as office_sso,
tbl_ate_jun.Voucher_Hours as office_hours
FROM
tbl_pd_jun,
tbl_ate_jun
WHERE
tbl_pd_jun.Project_Number=tbl_ate_jun.Voucher_Code AND tbl_pd_jun.Office_FSR = 'Y' 
)c,

(SELECT
tbl_ate_jun.person_sso as programs_sso,
tbl_ate_jun.Voucher_Hours as programs_hours
FROM
tbl_pd_jun,
tbl_ate_jun
WHERE
tbl_pd_jun.Project_Number=tbl_ate_jun.Voucher_Code AND tbl_pd_jun.Programs_FSR = 'Y'  
)d,

(SELECT
tbl_ate_jun.person_sso as total_sso,
tbl_ate_jun.Voucher_Hours as total_hours
from
tbl_ate_jun 
)e,


(SELECT
tbl_ate_jun.person_sso as diff_sso,
tbl_ate_jun.Voucher_Hours as diff_hours
from
tbl_ate_jun
WHERE voucher_code NOT IN (select project_number from tbl_pd_jun)
)f


where
a.person_sso=b.applied_sso
and a.person_sso=c.office_sso
and a.person_sso=d.programs_sso
and a.person_sso=e.total_sso
and a.person_sso=f.diff_sso

group by a.person_sso
Help, please. not every column is filled with a sum of data, some would be empty if it applies to the sso.

Published by: Jay on August 10, 2011 07:45

not every column is filled with a sum of data, some would be empty if it applies to the sso.

You will probably need to OUTER JOIN then...
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/queries006.htm#sthref3295
http://www.Oracle-base.com/articles/9i/ANSIISOSQLSupport.php#outer_join

Tags: Database

Similar Questions

  • I dealt with this problem for months. Even hired a comp tech to fix it and still have the same question. There, nobody helping me?

    I dealt with this problem for months.  Even hired a comp tech to fix it and still have the same question.  I had my computer wiped and windows 7 and 8 then reinstalled by a professional.  This all started when I upgraded form 7 to 8.  After 7 to 8 my computer kept getting this error. . kept crashing.  He was supposed to be fixed and it still does the same thing. I was told then move to 8.1.  I have always the same coming error.  I'm not on computer.  IS THERE ANYONE WHO KNOWS HOW TO FIX THIS?  Someone who can explain to me step by step how to fix?  I've tried everything.  Error 0x0000005c [settings 000000000000800 0x000000000000000B x 0 0 x 0000000000000000 0 x 0000000000000000]

    Hello

    The upgrade to 8.1 was perhaps not the best thing to do...

    A lot of people are having problems with it also.

    If it is a desktop computer, have you checked the wall outlet and the plug on the back of the computer?

    Your point about starting the tone certainly as a power or a hard disk problem...

    The problem with you mouse pointer could be related to a feature called quick start...

    Your other problem also, perhaps... Try to turn it off and see if it helps...

    This feature works only when you make a STOP and then start.

    It is not perform a RESTART.

    Turn on or off...

    Go to the control panel... Power options, and then select choose the power what buttons on the left.

    Then select change settings that are currently unavailable near the top center of the screen...

    Lower on the window, uncheck the quick start.

  • Please help me with this SQL query

    I'm practicing of SQL queries and met one involving the extraction of data from 3 different tables.

    The three paintings are as below

    < pre >
    Country
    Location_id country
    LOC1 Spain
    loc2 England
    LOC3 Spain
    loc4 USA
    loc5 Italy
    loc6 USA
    loc7 USA
    < / pre >
    < pre >


    User
    user_id location_id
    loc1 U1
    loc1 U2
    loc2 U3
    loc2 U4
    loc1 U5
    U6 loc3
    < / pre >
    < pre >


    Publish
    user_id post_id
    P1 u1
    P2 u1
    U2 P3
    P4 u3
    P5 u1
    P6 u2
    < / pre >

    I am trying to write a SQL query - for each country of the users, showing the average number of positions

    I understand the logic behind all this that we must first consolidate all locations, and then the users in one country and then find the way to their positions.
    But, I'm having a difficulty to this format SQL. Could someone help me please with this request.

    Thank you.

    Select
    Country.Country,
    Count (*) Totalpostspercountry,
    Count (distinct post.user_id) Totaldistincuserspercountry,
    count (*) / count (distinct post.user_id) Avgpostsperuserbycountry
    Of
    countries, have, post
    where country.location_id = muser.location_id
    and muser.user_id = post.user_id
    Country.country group

    The output is like this for your sample data - hope that's what you're looking for :)

    COUNTRY, TOTALPOSTSPERCOUNTRY, TOTALDISTINCUSERSPERCOUNTRY, AVGPOSTSPERUSERBYCOUNTRY
    In England, 1, 1, 1.
    Spain, 5, 2, 2.5.

  • Updates and extension for Dreamweaver CS5 do not install it? Someone at - he had problems with this before?

    Updates and extension for Dreamweaver CS5 do not install it? Someone at - he had problems with this before?

    Thank you Nancy for looking into this for me.  I have since adopted the web site of the company management

    Dream Weaver is a management tool of the great for the task I have on hand.

    Michael J. Lynch | Engineering support services

    Controls of Huntingtonhttp://www.huntingtoncontrols.com/>

    60 glacier Drive, Suite 2000 | Westwood | MY | 02090

    O: 781.535.6857x1025 | Direct line: 781.428.3310 | C: 617.334.4753

  • Can you please put me in touch with support for the trial version of adobe acrobat pro XI that I had tried on 15 March for 30 days. I tried to cancel because the cost is too, and Acrobat Reader are good for me. I can't uninstall program.

    Can you please put me in touch with support for the trial version of adobe acrobat pro XI that I had tried on 15 March for 30 days. I tried to cancel because the cost is too, and Acrobat Reader are good for me. I can't uninstall program.

    I had to wipe my drive since then with the trouble with Apple Store without acknowledging my machine and Time Machine reloading gave complications. Can you please cancel my trial and make my money from trial.

    Hi jack gordon.

    Adobe does not charge for the 30 day trial, but it seems that you have subscribed to Acrobat Pro (as a simple app for creative cloud membership) return March 15. To cancel your subscription, please contact customer service.

    Please let us know if you have any additional questions.

    Best,

    Sara

  • My IPad 2 Air is mad, he gets on its own, and it freezes. Not to mention it locks me. Didn't this iPad for 2 days. Have not been able to use it! I tried connecting to ITunes and will not work!

    My IPad 2 Air is mad, he gets on its own, and it freezes. Not to mention it locks me. Didn't this iPad for 2 days. Have not been able to use it! I tried connecting to ITunes and will not work!

    Hi Kareyfabela,

    For this kind of problem, I strongly recommended opening a pension with Apple iPad case will probably require inspection by an Apple engineer. You can open a file on this site: https://www.apple.com/support/contact/

    I hope this helps!

    Jonty

  • I need to reinstall my CS6 on my PC.  I installed it on this computer for 2 years now, but anyway half of subsequently moved to one of my hard drives and the other half is on the other.  I be sure to consider both drives off the coast and reinstall on the

    I need to reinstall my CS6 on my PC.  I installed it on this computer for 2 years now, but anyway half of subsequently moved to one of my hard drives and the other half is on the other.  I'm sure to remove both drives and reinstall on the larger hard drive?  I am a student and single MOM, and I can't afford the monthly subscription for the CC7.  If it does not somehow, I'll miss my classes.

    If the largest is the primary drive then it is safer than any other installation option, but all uninstall/reinstall can present problems.  If the software currently works very well, I would say that leave well enough alone if your future depends on software work.  Before you delete anything, remember to disable by opening an application and by choosing Help-> Deactivate.

  • I have a download latest apps just above bar tabs that has been there for 2 days now.

    I have a download the latest applications bar with a circle whirling above my tabs. He has been here for 2 days now. Any ideas?

    This has happened

    Each time Firefox opened

    Is Friday, June 10, 10

    Start Firefox in Firefox to solve the issues in Safe Mode to check if one of your modules is causing your problem (switch to the DEFAULT theme: Tools > Modules > themes).

    See the extensions, themes and problems of hardware acceleration to resolve common troubleshooting Firefox problems and troubleshooting questions with plugins like Flash or Java to solve common Firefox problems

  • I have not been able to get into my hotmail for 3 days now.

    original title: very well.

    I was not able to get into my hotmail for 3 days now, I thought it was due to the low-maintenance, but not it seems as if MICROSOFT itself IS down, can anyone of you answer the question?
    I'll make it easy for you to read.

    WHY DO I GET THIS MESSAGE FROM HOTMAIL, WHEN I TRY TO OPEN A SESSION?
    XML Parsing Error: not well-formed
    Location: http://by145w.bay145.mail.live.com/default.aspx?wa=wsignin1.0
    Number 328, column 51 line:
    --------------------------------------------------^
    If this continues to go I have no choice but to stop the use of microsoft products in my company.

    Hello

    The question you posted would be better suited in hotmail forums. View the query in the forums of hotmail for assistance.

     

    Hope that helps.

  • Strange problem with this SQL

    Hello

    I'm trying to concatenate the value of SQL_TEXT in multiple lines in a single string using this SQL statement. The problem is that it works fine if I use the PIECE, but if I use SQL_TEXT I get this error ORA-30004: when you use the SYS_CONNECT_BY_PATH function, cannot have a separator in the value of the column. As you can see I tried a number of separators I know are not in SQL_TEXT but still error. And help would be great.

    I tested on 11 GR 2 11.2.0.3 but need to run it on 10.2.0.4 so I can't use LISTAGG. I'm open to other methods but I don't have the ability to place and PLSQL nto the database. It must be done in SQL.
    select 
      CURRENT_SID, 
      sys_connect_by_path(PIECE,'~') -- Works
      --sys_connect_by_path(SQL_TEXT,'') -- Does Not Work
      -- trim(max(sys_connect_by_path(SQL_TEXT,'~')) keep (dense_rank last order by CURR),'~') as FULL_SQL_TEXT -- Does Not Work
      --ltrim(max(sys_connect_by_path(PIECE,'!')) keep (dense_rank last order by CURR),'!') as FULL_SQL_TEXT -- Does Not Work
    from
      (
      select 
          S.USERNAME, S.SID as CURRENT_SID, S.SERIAL#, T.PIECE,
          T.SQL_TEXT,
          ROW_NUMBER() over (partition by S.USERNAME, S.SID, S.SERIAL# order by T.PIECE) as CURR,
          ROW_NUMBER() over (partition by S.USERNAME, S.SID, S.SERIAL# order by T.PIECE) -1 as PREV
      from 
        V$SESSION S,
        V$SQLTEXT_WITH_NEWLINES T
      where 
        S.SQL_ID is not null
        and S.SQL_ID = T.SQL_ID
        and S.SID = sys_context('USERENV', 'SID')
      order by 
        T.PIECE
      )
    group by 
      CURRENT_SID
    connect by PREV = prior CURR
    start with CURR = 1;

    Hi SY,
    Thanks for the reply that your SQL worked very well. You're right about the GROUP BY and AGGREGATIONS, I had tried so many different things, I had pasted in a version with a bit of my test which was a little strange looking.

    The key was just as you say I was looking at my current SQL contained now my ' ~ 'or'!' delimiter. Thanks for all the help!

  • ODI 12 - problem with LKM SQL for Oracle

    Hi again,

    Three days ago, that I asked about the problem with the data types of data warehouses in models that were missing. After you apply the ideas suggested by Rita (thank you very much ) I got from their work.

    But after that, we came across a new problem. When you run a mapping (Oracle for Oracle databases), it failed on the second stage - ' "work table create. "When we checked the generated code was something like this: '(" CREATE TABLE < work_table_name >). None of the names of columns or data types have been described in parentheses and as expected, the ODI execution error was "invalid identifier". It seems that API odiRef.getColList(params)%> does not work. I tried loading using LKM Oracle Oracle (DB LINK) but once again the columns are missing in the generated script.

    I have to mention the master and work repositories are different databases from Oracle and ODI Agent is not installed because of some problems.

    We are still beginners of ODI and would appreciate any help from more experienced guy (or other beginners).

    Thank you in advance.

    Just by chance, we found the soluton today!

    The reason of missing generated code was that the description of the types of data was not entirely cofigured.

    We found that the fields "create table syntax" and "'syntax of data accessible in writing' in each type of data in the topology definition were empty." After filling them, the generation of the script is running properly.

    Before that we had problems with missing data types in models and we realized the reverse engineering of the types of data, but obviously it is insufficient.

    Thanks to all those who participated in the discussion and tried to help us!

  • Had problem with this tut :D

    Hello.

    I want to understand ho to make the text of the flame. I mean text flame really like this tut:http://10steps.sg/tutorials/photoshop/text-on-fire-effect/ but I want to do in illustrator.

    I fount this tut: http://www.ehow.com/how_12030846_make-flaming-text-illustrator.html but I had problem with step 6 in efect coz > transorm and disort > tweak (I invited this tweak in English) are nothing else then move object transform :/

    I want to ask you guys what is the shortcut for the tweak option coz I thikn im using the wrong option but others in this menu drop-down doesn't seem to have good option too when we reading this tutorial.

    Thx for the answer

    See you soon

    There is no shortcut...

    Maybe a picture will help you...

    I hope never tutorials if they did not all images. At the very least, an image showing final results.

  • What wrong with this sql?

    What wrong with my sql? When I try to run a plain explain command against it. I get it that perfectly well... If the syntax was wrong, I won't get the plan to explain it, then why am I getting an error number invalid? What is the data? I'm on 10.2.0.3

    Published by: S2K on August 18, 2009 10:21

    Check out this site that has a lot of regular expressions submitted by users: [Library of regular expressions | http://regexlib.com/DisplayPatterns.aspx?cattabindex=2&categoryId=3]

    Then you should do something like you posted:

    WHERE REGEXP_LIKE(RSLT_QTY,)
    
  • Hi, I bought a student version for 15 Euros per month, but I had only a trial version for 30 days. Can someone tell me, what is the problem.

    Hi, I bought a student abo and each month 15 euros are charged out of my bank account, but I had only a trial version or 30 days. What the problem? Best, Peter

    Your subscription to cloud shows correctly on your account page?

    If you have more than one email, you will be sure that you use the right Adobe ID?

    https://www.adobe.com/account.html for subscriptions on your page from Adobe

    .

    If Yes

    Sign out of your account of cloud... Restart your computer... Connect to your paid account of cloud

    -Connect using http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html

    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html

    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html

    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html

    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp

    -http://helpx.adobe.com/creative-cloud/kb/license-this-software.html

    .

    If no

    This is an open forum, Adobe support... you need Adobe personnel to help

    Adobe contact information - http://helpx.adobe.com/contact.html

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    -Select your product and what you need help with

    -Click on the blue box "still need help? Contact us. "

  • My account has been blocked, and it will not send a code to my phone. There is absolutely no way to close an account that I have and I tried for 2 days now. Please help as soon as POSSIBLE.

    I need the (* address email is removed from the privacy *) account closed immediately. She has been compromised and now blocked. I changed the password several times now and it always sends me on this page of the blocked account where he asks your mobile phone number. I put my phone number in over 10 times now and I still have not received anything. I was even on the phone with tech support and they said they couldn't help me. This becomes very very frustrating when all I want is the account completely closed/deleted/completed. Help, please.

    Hello

    For assistance with Windows Live IDs, you will need to post on the Windows Live help site. See the following links:

    http://windowslivehelp.com/solution.aspx?SolutionID=6ea0c7b3-1473-4176-b03f-145b951dcb41

    https://windowslivehelp.com/PasswordReset.aspx

Maybe you are looking for

  • Blocked contacts can see that they are blocked

    It happens with everyone? If I block someone from my contact list, they can see that showing me in their list of contacts as that user with a question mark instead of a regular icon. Is it possible to fix it?

  • Drivers not listed for Tecra A3 (PTA30A)

    I followed the logical structure of the site and went through this link: http://www.ISD.Toshiba.com.au/drivers Drill down to find only 13 drivers listed more which are for windows 2000 (fat lot of use of our days). However, most of the drivers chipse

  • Impossible to install ipv6

    When I pull up to the selection of the pilot network protocol dialog box appearswithout a digitally signed icon and when I click on it, I get an error message: Could not add the required component. The error is: the parameter isincorrect answer. When

  • Try to delete the notice of entry reaccoring

    I bought a Compaq Paesario laptop because I was in an auto access, I didn't register the unit until three years later, I filled of the enrolment notice that appeared on the screen, his answer was ' congratulations, you've managed to the commercial re

  • BlackBerry Smartphones HTML format for composing emails on Curve 8330

    Anyone know if it is possible to compose a message in HTML, not plain text on a Curve 8330?  If I receive a message that is created in HTML format, it shows as sent and if I send, it is sent using HTML format.  When I compose a new message, it is alw