Small modification needed in sql query.

Hi OTN,
I have Below Query in which i'am fetching the Data from Target Aggregation Table.
select
TARGET_EMPLOYEE.FIRST_NAME||' ' ||TARGET_EMPLOYEE.LAST_NAME as Requestername,
TARGET_EMPLOYEE.GE_ID as requesterGEID,
TARGET_ATTENDEE.FIRST_NAME||' ' ||TARGET_ATTENDEE.LAST_NAME as AttendeeName,
TARGET_ATTENDEE.ATTENDEE_TYPE_FLAG as Attendeetyflg,
TARGET_ATTENDEE.US_GO_ATTENDEE_FLAG as usgoflg,
TARGET_ATTENDEE.COMP_GOVT_AGENCY_DEPT as Atcomp,
TARGET_ATTENDEE.COUNTRY as atcountry,
TARGET_AGGREGATION_ATTENDEE.REQUEST_TYPE as requesttype,
TARGET_PA_REQUEST.PA_REQUEST_ID as parequest,
TARGET_PA_REQUEST.EVENT_DATE as eventdate,
TARGET_PA_REQUEST.EVENT_DESCRIPTION as eventdesc,
TARGET_PA_REQUEST.CREATED_DATE as requestdate,
TARGET_PA_REQUEST.STATUS as status,
TARGET_AGGREGATION_ATTENDEE.status,
TARGET_AGGREGATION_ATTENDEE.be_aggregation_approved_amount as approved_amount,
TARGET_AGGREGATION_ATTENDEE.level_id,
TARGET_AGGREGATION_ATTENDEE.be_aggregation_pend_amount as req_amount
from TARGET_ATTENDEE,
TARGET_EMPLOYEE,
TARGET_PA_REQUEST,
TARGET_AGGREGATION_ATTENDEE
where TARGET_ATTENDEE.ATTENDEE_ID=TARGET_AGGREGATION_ATTENDEE.ATTENDEE_ID
and TARGET_EMPLOYEE.GE_ID=TARGET_AGGREGATION_ATTENDEE.REQUESTOR_ID
and TARGET_AGGREGATION_ATTENDEE.PA_REQUEST_ID=TARGET_PA_REQUEST.PA_REQUEST_ID
and to_char(TARGET_AGGREGATION_ATTENDEE.CREATED_DATE,'YYYY')=to_char(sysdate,'YYYY')
and TARGET_AGGREGATION_ATTENDEE.pa_request_id='NAM1421';
for fetching particular request id: NAM1421
i'am getting output:
REQUESTERNAME     REQUESTERGEID     ATTENDEENAME     ATTENDEETYFLG     USGOFLG     ATCOMP     ATCOUNTRY     REQUESTTYPE     PAREQUEST     EVENTDATE     EVENTDESC     REQUESTDATE     STATUS     STATUS_1     APPROVED_AMOUNT     LEVEL_ID     REQ_AMOUNT
Danny Leung     1000650742     Mano hariram     Y     Y     BSNL     India     BE     NAM1421     13-AUG-12     fdg     13-AUG-12     APD               15     3
Danny Leung     1000650742     Mano hariram     Y     Y     BSNL     India     BE     NAM1421     13-AUG-12     fdg     13-AUG-12     APD     Approved     3     70     0
Danny Leung     1000650742     Mano hariram     Y     Y     BSNL     India     BE     NAM1421     13-AUG-12     fdg     13-AUG-12     APD               20     3
But i need output like :
Requested Amount, Approved Amount, Approved status in a single row.
getting Requested Amount from TARGET AGGREGATION TABLE
LOGIC: where Level_id should minimum that Levelid we have to get into Requested Amount.
for Getting Approved Amount: where the status should be approved that corresponding amount should be in Approved Amount column.
Thanks

hi Matthew,
I need output of above query like:
in the Requested Amount Column from Target Aggregation Table should give (corresponding value of minimum Level id).
In the Approved Amount Column from Target Aggregation Table should Give (Corresponding value of Approved status).
Please suggest me how to achieve it.
Table Data of Target Aggregation Table:
PA_REQUEST_ID     STATUS     APPROVED_AMOUNT     LEVEL_ID     REQ_AMOUNT
APAC1031     CAN          0     0.61336
APAC1031     CAN          0     8.17212
APAC1031     CAN          30     0
APAC1031     CAN          30     0     
APAC3873               0     
APAC3873               80     
APAC3873               0     
APAC3873               80     
APAC3873               30     
APAC3873               70     
APAC3873               30     
APAC3873     Approved          80     
APAC3873               60          
APAC3997     Approved     0.08     80     0
APAC3997     Approved          80     
APAC3997     Approved          80     
APAC3997               30     
APAC3997               30     0.08
APAC3997               30     
APAC3997               0     
APAC3997               0     0.08
APAC3997               0     
APAC3997               60     
APAC3997               60     0.08
APAC3997               60     
APAC3998               0     
APAC3998               30     
APAC3998               0     
APAC3998               0     
APAC3998               30     
APAC3998               30     
APAC4001               0     
APAC4004               30     
APAC4004               30     
APAC4004               0     
APAC4004               0     
APAC4004               80     
APAC4004               0     
APAC4004               80     
APAC4004               0     
APAC4004               60     
APAC4006               30     
APAC4006               30     
APAC4006               0     
APAC4006               0     
APAC4007               0     
APAC4007               0     0.08
APAC4008               30     0.06
APAC4008     Approved     0.06     80     0
APAC4008               60     0.06
APAC4008               0     0.06
APAC4009               0     10
APAC4009               0     10
APAC4010               0     
APAC4010               60     
APAC4010               30     
APAC4010     Approved          80     
APAC4011               30     
APAC4011               30     0.68
APAC4011               0     
APAC4011               0     0.68
APAC4013               30     
APAC4013               30     
APAC4013               0     
APAC4013               30     
APAC4013               0     
APAC4013               0     
APAC4014               30     
APAC4014               30     0.9
APAC4014               0     
APAC4014               0     0.9
APAC4016               0     
APAC4016               0     
APAC4016               30     
APAC4016               30     
APAC4017     CAN          30     
APAC4017     CAN          30     
APAC4017     CAN          60     
APAC4017     CAN          60     
APAC4017     CAN          60     
APAC4017     CAN          70     
APAC4017     CAN          70     
APAC4017     CAN          70     
APAC4017     CAN          80     
APAC4017     CAN          80     
APAC4017     CAN          80     
APAC4017     CAN          30     
APAC4017     CAN          0     
APAC4017     CAN          0     
APAC4017     CAN          0     
APAC4019               60     0.08
APAC4019     Approved          80     
APAC4019     Approved     0.08     80     0
APAC4019               30     
APAC4019               60     
APAC4019               30     0.08
APAC4019               0     0.08
APAC4019               0     
APAC4023     Rejected          0     0.12
APAC4025     CAN          80     
APAC4025     CAN          80     
APAC4025     CAN          0     
APAC4025     CAN          0     
APAC4025     CAN          0     
APAC4025     CAN          30     
APAC4025     CAN          30     
APAC4025     CAN          30     
APAC4025     CAN          60     
APAC4025     CAN          60     
APAC4025     CAN          60     
APAC4025     CAN          70     
APAC4025     CAN          70     
APAC4025     CAN          70     
APAC4025     CAN          80     
APAC4027               80     
APAC4027               80     
APAC4027               80     
APAC4027               70     
APAC4027               70     
APAC4027               70     
APAC4027               60     
APAC4027               60     
APAC4027               60     
APAC4027               30     
APAC4027               30     
APAC4027               30     
APAC4027               0     
APAC4027               0     
APAC4027               0     
APAC4028               60     
APAC4028               0     
APAC4028               0     
APAC4028               70     
APAC4028               70     
APAC4028               70     
APAC4028               60     
APAC4028               60     
APAC4028               30     
APAC4028               30     
APAC4028               30     
APAC4028               0     
APAC4029     Rejected          0

Similar Messages

  • Need a SQL query(Pls Its urgent)

    Hi,
    I want a SQL query for the foll..
    Details r below..
    Table AFPFTRAN
    BU TRansactiondate Amt
    13202 10-04-05 10,000
    13203 11-05-05 20,000
    13202 20-04-05 5,000
    Table AFGENCOD
    BU Clerk Name Clerk Code
    13202 Amit TFBG
    13203 Anand TFMG
    I want a query to get data as below..
    Tr Date TFBG TFMG
    Apr 15,000 0
    May 0 20,000
    JUn 0 0
    Jul 0 0
    Aug
    Sep
    Aug
    Nov
    DEc
    Jan
    Feb
    Mar
    I want this to achieve using a single query...?How can I achive this?
    Pls give the sol...
    Adios...
    Prashanth Deshmukh

    Does it look like you need ?
    SQL> select * from t;
            BU TDATE           AMT
         13202 10.04.05      10000
         13203 11.05.05      20000
         13202 20.04.05       5000
    SQL> select * from t1;
            BU NAME  CODE
         13202 Amit  TFBG
         13203 Anand TFMG
    SQL> SELECT pivot_month.mname, tops.TFBG, tops.TFMG
      2  from
      3  (
      4  select to_char(t.tdate,'MM') month_no,
      5  sum(decode(t1.code,'TFBG',t.amt,0)) TFBG,
      6  sum(decode(t1.code,'TFMG',t.amt,0)) TFMG
      7  from t1, t
      8  where t.bu=t1.bu
      9  and to_char(t.tdate,'yyyy') = 2005
    10  GROUP BY t1.code, to_char(t.tdate,'MM')
    11  ) tops,
    12  (select rownum mn, to_char(to_date(rownum,'MM'),'MON') mname,
    13  case when rownum between 1 and 3 then rownum + 9
    14  else rownum - 3 end rn
    15  from dict where rownum < 13) pivot_month
    16  where pivot_month.mn = tops.month_no (+)
    17  order by pivot_month.rn
    18  /
    MNA       TFBG       TFMG
    APR      15000          0
    MAY          0      20000
    JUN
    JUL
    AUG
    SEP
    OCT
    NOV
    DEC
    JAN
    FEB
    MAR
    12 rows selected.Rgds.

  • Proxy to JDBC scenario need dynamic sql query for sender .

    Hi Experts,
    I am developing proxy to jdbc scenario. in this i need to pass dynamic sql query  whre we are passing classical method like below.
    while we are passing select stmt in constant and mapped with access field  and key field mapped with key field.
    MY requirement is like instead of passing select stmt in constant where i can generate dynamically and passed in one field and mapped with access field.

    Hi Ravinder,
    A simple UDF or use of graphical mapping functions in most cases should provide you everything you need to construct a dynamic SQL statement for your requirement.
    Regards,
    Ryan Crosby

  • Need a SQL Query (URGENT)

    Hi Folks,
    I have 2 tables, in which the 1st one has 200 columns and 2 table had 2 columns.. There is one common column for both the tables, but there is little change in schema of the tables...The common col in 2nd table is a primary key but the same column in the 1st table is a ordinary one..The data type for the common column is same...
    Now i need to write a query to select 199columns(except the common column)from the 1st table and the other column(2nd col)other than the common column frm the 2nd table for "table1.commoncolumn=table2.commoncolumn"......
    I had tried the natural join but its nt working in my informix sql database....I also tried by explicitly mentioning column names like "select column1,column2....column199,table2.column2 from table1,table2 where table1.commoncolumn=table2.commoncolumn", but its having a severe performance impact.......
    Can some please suggest a query for the above one?? Thankx in advance..

    Please gimme possible solutions & suggestions regarding the above query....
    The informix z forum very slow...The problem is, you labeled your questions badly. As this is a forum of volunteers people tend to react badly to the use of the word "urgent" in the subject line. Nobody's question matters more than anybody else's. In fact some regulars won't answer questions with "urgent" in the strapline as a matter of principle.
    Then when we get to actually read your question it turns out to be a question about Informix. I guess not many people here use Informix so your potential pool of responders is pretty small (for instance I'm not even sure how to spell it).
    It's not our fault the Informix forums are so lame.
    Anyway, what I suggest is you repost your question with a new title: (Off topic) Need help with an INFORMIX query.
    At least that will attract people who might be able to answer your question. Then you need to include the actual query you're running and all the supporting details necessary for people to understand the nature of the performance impact.
    You need to ask the right people and you need to ask the right question. This is standard etiquette (and indeed common sense) regardless of which forum you're using.
    Cheers, APC
    Blog : http://radiofreetooting.blogspot.com/

  • Help needed for SQL query

    hello ,
    I am a beginner in terms of writing sql queries. I hope some body can help me out.
    I have two tables
    mysql> desc user_group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | userAccountId | char(8) | | PRI | | |
    | groupId | char(8) | | PRI | | |
    ---------------------------------------------------+
    2 rows in set (0.00 sec)
    mysql> desc group_t;
    ---------------------------------------------------+
    | Field | Type | Null | Key | Default | Extra |
    ---------------------------------------------------+
    | id | char(8) | | PRI | | |
    | name | char(50) | YES | | NULL | |
    | email | char(100) | YES | | NULL | |
    | description | char(254) | YES | | NULL | |
    | parentId | char(8) | YES | | NULL | |
    | creatorId | char(8) | YES | | NULL | |
    | createDate | char(20) | YES | | NULL | |
    | updateDate | char(20) | YES | | NULL | |
    | updatorId | char(8) | YES | | NULL | |
    ---------------------------------------------------+
    9 rows in set (0.00 sec)
    what I want is list of all groups with id,name and #of members(which is the # of rows in the user_group_t for any given id). Importantly I need the groups with 0 members also to be listed. In short my output should contain exactly the same number of rows as in group_t table with an additional column indicating # of members for that group.
    Any help would be greatly appreciated.
    Thanks in Advance.
    -Vasanth

    Thanks Donald,
    Actually I figured it out, with the following query:
    select id,name,sum(if(groupid is not null,1,0)) as members from group_t left join user_group_t on id=groupid group by id;
    I tried your solution, but mysql says there is an error at '+' . Anyway I modified your solution to the one below and it worked.
    select a.id, a.name, count(b.groupid) from group_t a left join user_group_t b on a.id=b.groupid group by a.id, a.name;
    I tried that before but then I used Count(*) instead of count on groupid. Your solution is elagant and I will go with yours.
    Thanks again.
    Vasanth

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • Help Needed In SQL Query

    HI All,
    Oracle sql clarification required
    Sample Table:
    empno empname Job mgr_id hire_date salary deptno
    7788 SCOTT ANALYST 7566 19-APR-87 3000 20
    7902 FORD ANALYST 7566 03-DEC-81 3000 20
    7934 MILLER CLERK 7782 23-JAN-82 1300 10
    7900 JAMES CLERK 7698 03-DEC-81 950 30
    7369 SMITH CLERK 7902 17-DEC-80 800 20
    7876 ADAMS CLERK 7788 23-MAY-87 1100 20
    Need "single / one" sql for this requirement statement:
    There will be 2 drop down boxes (1st - Job list, 2nd - empno) in the form in which the following result set is expected
    1) When user selects value from 1st drop down box (job) as "ANALYST" leaving the second drop down unselected, the result expected is 2 (no. of rows for that job)
    2) When user selects value from 1st drop down box (job) as "ANALYST" and the value from 2nd drop down box as 7902, the result expected is 1 (no of rows for that job and empno)
    Sqls which I have tried from my side (given below) didn't give the expected result and please do help me in correcting this
    select count(1) from scott.emp where job='ANALYST' and ( empno = :empno or empno is null ) ;
    Please help for this requirement. Any help is deeply appreciated.
    Thanks
    Zaheer

    Hi,
    welcome to the forum.
    Please read SQL and PL/SQL FAQ
    When you put some code or output please enclose it between two lines starting with {noformat}{noformat}
    i.e.:
    {noformat}{noformat}
    SELECT ...
    {noformat}{noformat}
    For your question the following will both work:SQL> select * from emp
    where job='ANALYST' and (empno =:empno or :empno is null)
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
    7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
    2 rows selected.
    SQL> select * from emp
    where job='ANALYST' and empno =NVL(:empno, empno)
    EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
    7788 SCOTT ANALYST 7566 19/04/1987 00:00:00 3000 20
    7902 FORD ANALYST 7566 03/12/1981 00:00:00 3000 20
    2 rows selected.
    Regards.
    Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need a sql query to get the difference between two timestamp in the format of hh:mm:ss.msec

    I have a database table where it keeps record of the transaction when it starts at StartTime and when it ends at EndTime. Both these entries are having the timestamp entries. Say for example, I have a tuple with Entries like 'Transaction A' starts at '2014-05-07
    20:55:03.170' and ends at '2014-05-08 08:56:03.170'. I need to find the difference between these two timestamps and my expected output is 12:01:00.000. Let me know how to achieve this ? 

    Hi,
    You can use below script which calculates difference as DD:HH:MM:SS. You can modify the same:
    DECLARE @startTime DATETIME
    DECLARE @endTime DATETIME
    SET @startTime = '2013-11-05 12:20:35'
    SET @endTime = '2013-11-10 01:22:30'
    SELECT [DD:HH:MM:SS] =
    CAST((DATEDIFF(HOUR, @startTime, @endTime) / 24) AS VARCHAR)
    + ':' +
    CAST((DATEDIFF(HOUR, @startTime, @endTime) % 24) AS VARCHAR)
    + ':' +
    CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
    THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
    ELSE
    CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
    AS VARCHAR)
    END
    + ':' + CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR),
    [StringFormat] =
    CAST((DATEDIFF(HOUR , @startTime, @endTime) / 24) AS VARCHAR) +
    ' Days ' +
    CAST((DATEDIFF(HOUR , @startTime, @endTime) % 24) AS VARCHAR) +
    ' Hours ' +
    CASE WHEN DATEPART(SECOND, @endTime) >= DATEPART(SECOND, @startTime)
    THEN CAST((DATEDIFF(MINUTE, @startTime, @endTime) % 60) AS VARCHAR)
    ELSE
    CAST((DATEDIFF(MINUTE, DATEADD(MINUTE, -1, @endTime), @endTime) % 60)
    AS VARCHAR)
    END +
    ' Minutes ' +
    CAST((DATEDIFF(SECOND, @startTime, @endTime) % 60) AS VARCHAR) +
    ' Seconds '
    Reference:
    http://sqlandme.com/2013/12/23/sql-server-calculating-elapsed-time-from-datetime/
    - Vishal
    SqlAndMe.com

  • Need a sql query to get multiple dates in rows

    Hi All,
    i need a query to get dates for last 7 days and each dates should be in one row...
    but select sysdate from dual..gives one row...
    Expexcted Output
    Dates:
    01-oct-2013
    30-sep-2013
    29-sep-2013
    28-sep-2013
    27-sep-2013
    26-sep-2013

    Hi,
    Do you mean that you want all 7 dates together on 1 row?
    Here's one way:
    SELECT LISTAGG ( TO_CHAR ( SYSDATE + 1 - LEVEL
                              , 'DD-Mon-YYYY'
                    ) WITHIN GROUP (ORDER BY LEVEL)    AS txt
    FROM    dual
    CONNECT BY LEVEL <= 7
    This is an example of String Aggregation, that is, taking a column on multiple rows, and concatenating all the values (however many htere happen to be) into 1 big string column 1 row.
    Like everything else, exactly how to do it depends on your Oracle version.
    For more on String Aggregation, including differetn techniques for different versions, see http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    Message was edited by: FrankKulash
    Sorry, I mis-read the question.

  • Need the sql query

    Hi All,
    i have data like in table
    ename dept sal
    anbu ece 2000
    anbu ece 3000
    anbu csc 4000
    raj csc 5000
    need output only the same ename,same dept ,diffrent sal
    ename dept sal
    anbu ece 2000
    anbu ece 3000
    please give me the out put ...

    select ename
         , dept
         , sal
      from (
    select ename
         , dept
         , sal
         , count(*) over (partition by ename, dept) cnt
      from test
    where cnt > 1like in
    SQL> with test as
      2  (
      3  select 'anbu' ename, 'ece' dept, 2000 sal from dual union all
      4  select 'anbu' ename, 'ece' dept, 3000 sal from dual union all
      5  select 'anbu' ename, 'csc' dept, 4000 sal from dual union all
      6  select 'raj'  ename, 'csc' dept, 5000 sal from dual
      7  )
      8  select ename
      9       , dept
    10       , sal
    11    from (
    12  select ename
    13       , dept
    14       , sal
    15       , count(*) over (partition by ename, dept) cnt
    16    from test
    17    )
    18   where cnt > 1
    19  /
    ENAM DEP        SAL
    anbu ece       2000
    anbu ece       3000
    SQL>

  • Need efficient SQL query to retrieve data for MLM website

    Table cd_members
    MemberID LeftID RightID
    1 2 3
    2 4 5
    3 6 7
    4 8 -
    5 - -
    6 - -
    7 - -
    8 9 10
    9 - -
    10 - -
    i want to execute a query to retrieve downline of a member say MemberID 2
    o/p should be Records with MemberID 4,5,8,9,10
    i am using this query but don't know how to start from MembeID=2
    select a.memberid, a.tradingid, a.refid, a.parentid, a.node, a.leftid, a.rightid, b.memberid from cd_members a, cd_members b
    where (a.leftid=b.memberid or a.rightid=b.memberid)

    Again, assuming that the number of levels is known, you can just do N self joins (note that I intentionally go one level further than necessary in this case
    SQL> ed
    Wrote file afiedt.buf
      1  with t
      2    as
      3   (
      4      select 1 person, 2 left, 3 right from dual union all
      5      select 2, 4, 5 from dual union all
      6      select 3, 6, 7 from dual union all
      7      select 4, 8, null from dual union all
      8      select 5, null, null from dual union all
      9      select 6, null, null from dual union all
    10      select 7, null, null from dual union all
    11      select 8, 9, 10 from dual union all
    12      select 9, null, null from dual union all
    13      select 10, null, null from dual
    14   )
    15   select t1.left, t1.right, t2.left, t2.right, t3.left, t3.right, t4.left, t
    4.right
    16     from t t1,
    17          t t2,
    18          t t3,
    19          t t4
    20    where t1.person = 2
    21      and t1.left = t2.person(+)
    22      and t2.left = t3.person(+)
    23*     and t3.left = t4.person(+)
    SQL> /
          LEFT      RIGHT       LEFT      RIGHT       LEFT      RIGHT       LEFT
         RIGHT
             4          5          8                     9         10Justin

  • Need the sql query for IN clause.

    Hi All,
    i have item data like --
    IBM 200 and IBM 500
    have present code like this ----select * from emp where in (IBM 200 and IBM 500);
    so i need change or repalce like ('IBM 200','IBM 500')
    Any body please help me out this..
    Need to get out put 'IBM 200','IBM 500' from data IBM 200 and IBM 500 ...
    Edited by: anbarasan on Oct 17, 2011 10:30 PM

    Please consider the following when you post a question. This would help us help you better
    1. New features keep coming in every oracle version so please provide Your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good Search Feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a *Performance Related Question*. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.
    8. Please keep in mind that this is a public forum. Here No question is URGENT.
       So use of words like *URGENT* or *ASAP* (As Soon As Possible) are considered to be rude.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need the SQL Query to check SQL time zone and change the time zone

    Hi All,
    I am using SQL Server 2008 SP2. My Ex SQL Admin said that the data which we query from our database gives the output in London time.
    But the SQL server is located in USA and is having US time.
    I would like to know how to find what time zone is the SQL application running on and how to change it ?
    Is there any query which i can use to determine and change the time zone ?
    Gautam.75801

    Refer the below two links
    http://blog.sqlauthority.com/2014/02/15/sql-server-get-current-timezone-name-in-sql-server/
    Check this link
    http://dba.stackexchange.com/questions/39421/how-to-handle-timezone-properly-in-sql-server
    SELECT [DateTimeUtil].[UDF_ConvertLocalToLocalByTimezoneIdentifier] (
    'GMT Standard Time', -- the original timezone in which your datetime is stored
    'Middle East Standard Time', -- the target timezone for your user
    '2014-03-30 01:55:00' -- the original datetime you want to convert
    --Prashanth

  • Need An SQL Query

    Hello,
    Kindly have a look at two tables…
    Item_Master
    Item_Code Item_Name    
    1          ParentA    
    2          ChildA         
    3          ChildB         
    4          ChildC         
    5          ParentB    
    BOM_Relation
    Parent_ID Child_ID Quantity
    1          2          10
    1          3          20
    5          4          5
    5          2          5I required output like below…
    Parent_ID Parent_Name Child_ID Child_Name Quantity
    1          ParentA     2          ChildA          10
    1          ParentA     3          ChildB          20
    5          ParentB     4          ChildC          5
    5          ParentB     2          ChildA          5What will be the query for this?
    Thanks in advance!!
    Regards,
    Chetan

    select p.item_code,p.item_name,c.item_code,c.item_name,d.quantity
    from item_master p,item_master c,item_detail d where
    p.item_code = d.item_code and
    c.item_code = d.item_code;

  • Need help - sql query

    Hi,
         I have two tables(production & sales). I want to generate monthly statement. The followings are the sample data.
    PRODUCTION:
    DATE          MATERIAL     WEIGHT      AMOUNT
    01/12/2008     Item1     300     6000
    03/12/2008     item2          250      3500
    07/12/2008     item3          700     6500
    12/12/2008     item1          200     4000
    20/12/2008     item3          400     9600
    25/12/2008     item1          250     5000
    Sales:
    SAL_Date          Sal_Material     sal_weight     SAL_Amount
    12/12/2008     item3          270     2300
    15/12/2008     item1          200     4000
    20/12/2008     item2          250     3500
    20/12/2008     item1          100     2000
    23/12/2008     item1          100     2000
    27/12/2008     item3          200     3500
    I want to generate monthly statement like the following....
    Required Report:
    Date          Production          Sales
              Weight - Amount      Weight - Amount          
    01/12/2008     300     6000          0     0
    02/12/2008     0     0     0     0
    03/12/2008     250     3500          0     0           
    04/12/2008     0 0 0 0
    07/12/2008     700 6500 0 0
    12/12/2008     200     4000     270 2300
    31/12/2008 0 0 0 0
    i don't know, how to generate sequential date...
    Could you please tell me the query?
    Thanks & Regards

    SQL> with prod
      2  as
      3  (
      4     select to_date('01/12/2008','dd/mm/yyyy') dt, 'Item1' material, 300 weight, 6000 amount from dual union all
      5     select to_date('03/12/2008','dd/mm/yyyy'), 'item2', 250, 3500 from dual union all
      6     select to_date('07/12/2008','dd/mm/yyyy'), 'item3', 700, 6500 from dual union all
      7     select to_date('12/12/2008','dd/mm/yyyy'), 'item1', 200, 4000 from dual union all
      8     select to_date('20/12/2008','dd/mm/yyyy'), 'item3', 400, 9600 from dual union all
      9     select to_date('25/12/2008','dd/mm/yyyy'), 'item1', 250, 5000 from dual
    10  ), sales
    11  as
    12  (
    13     select to_date('12/12/2008','dd/mm/yyyy') dt, 'item3' material, 270 weight, 2300 amount from dual union all
    14     select to_date('15/12/2008','dd/mm/yyyy'), 'item1', 200, 4000 from dual union all
    15     select to_date('20/12/2008','dd/mm/yyyy'), 'item2', 250, 3500 from dual union all
    16     select to_date('20/12/2008','dd/mm/yyyy'), 'item1', 100, 2000 from dual union all
    17     select to_date('23/12/2008','dd/mm/yyyy'), 'item1', 100, 2000 from dual union all
    18     select to_date('27/12/2008','dd/mm/yyyy'), 'item3', 200, 3500 from dual
    19  ),find_date
    20  as
    21  (
    22     select dt st, last_day(dt) ed
    23       from (select distinct trunc(dt,'month') dt from prod
    24             union
    25             select distinct trunc(dt,'month') dt from sales)
    26  ),day_list
    27  as
    28  (
    29     select (level-1)+st dt
    30       from find_date
    31     connect by level <= (ed - st)+1
    32  )
    33  select d.dt, t.p_weight, t.p_amount, t.s_weight, t.s_amount
    34    from day_list d
    35    left join
    36         (select decode(p.dt,null,s.dt,p.dt) dt,
    37                    sum(p.weight) p_weight, sum(p.amount) p_amount, sum(s.weight) s_weight, sum(s.amount) s_amount
    38            from prod p
    39            full outer join sales s
    40              on p.dt = s.dt
    41             and p.material = s.material
    42           group by decode(p.dt,null,s.dt,p.dt)) t
    43      on d.dt = t.dt
    44  order by d.dt
    45  /
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    01-DEC-08        300       6000
    02-DEC-08
    03-DEC-08        250       3500
    04-DEC-08
    05-DEC-08
    06-DEC-08
    07-DEC-08        700       6500
    08-DEC-08
    09-DEC-08
    10-DEC-08
    11-DEC-08
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    12-DEC-08        200       4000        270       2300
    13-DEC-08
    14-DEC-08
    15-DEC-08                              200       4000
    16-DEC-08
    17-DEC-08
    18-DEC-08
    19-DEC-08
    20-DEC-08        400       9600        350       5500
    21-DEC-08
    22-DEC-08
    DT          P_WEIGHT   P_AMOUNT   S_WEIGHT   S_AMOUNT
    23-DEC-08                              100       2000
    24-DEC-08
    25-DEC-08        250       5000
    26-DEC-08
    27-DEC-08                              200       3500
    28-DEC-08
    29-DEC-08
    30-DEC-08
    31-DEC-08
    31 rows selected.

Maybe you are looking for

  • How to restore or backup Apex application from Command line ? URGENT

    We have Oracle apex 4.1 installed in Oracle 11g R2 database (windows 64-bit) 2008 R2 For some reason our database dictionary objects are corrupted. We wanted to backup our Apex applications in some workspaces ASAP. We are not able to access apex from

  • Ilife 11 software upgrade failing and crashing with clicking noise happens

    HELP after upgrading my 09 macbook pro to the ilife 11 software. all the others work fine, but iphoto has worked but it says before i can use it, I need to upgrade my library and about less than a 1/3 done it crashed and my mac makes a weird clicking

  • SAP CAL issue Activating HANA instance on AWS

    My CAL instance of openSAP Course: Introduction to Software Development on SAP HANA 2013.01 is stuck in Activating status. I had previously deactivated my AWS account, and have now reactivated it.  I got an error when trying to active the instance th

  • Temporary errors automatically deletes the work item.

    Hi, I have a background workflow task which calls a ABAP class & method. The method raises the temporary exception, cx_bo_action_cancelled when an error occurs. However, when the workflow catches this exception, the corresponding work item (belonging

  • Changing path of recorded streams

    i changed the path of the recorded streams in application.xml in the tag <StorageDir> after it i can not enter to the administration console the comment is "connection failed" what should i do?