Please help with this query!

Hi All,
I have this this table:
Term Grade
term_A A
term_A A
term_A B
term_A B
term_B D
term_B F
term_B F
term_C C
How do I display so that it appears this way?
term_A A 2
term_A B 2
term_B D 1
term_B F 2
term_C C 1
Thank you. Appreciate all the help!

Please read about [url http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14200/functions001.htm#sthref962]aggregate functions in the manual.
Regards,
Rob.

Similar Messages

  • Please need help with this query

    Hi !
    Please need help with this query:
    Needs to show (in cases of more than 1 loan offer) the latest create_date one time.
    Meaning, In cases the USER_ID, LOAN_ID, CREATE_DATE are the same need to show only the latest, Thanks!!!
    select distinct a.id,
    create_date,
    a.loanid,
    a.rate,
    a.pays,
    a.gracetime,
    a.emailtosend,
    d.first_name,
    d.last_name,
    a.user_id
    from CLAL_LOANCALC_DET a,
    loan_Calculator b,
    bv_user_profile c,
    bv_mr_user_profile d
    where b.loanid = a.loanid
    and c.NET_USER_NO = a.resp_id
    and d.user_id = c.user_id
    and a.is_partner is null
    and a.create_date between
    TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
    TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    order by a.create_date

    Perhaps something like this...
    select id, create_date, loanid, rate, pays, gracetime, emailtosend, first_name, last_name, user_id
    from (
          select distinct a.id,
                          create_date,
                          a.loanid,
                          a.rate,
                          a.pays,
                          a.gracetime,
                          a.emailtosend,
                          d.first_name,
                          d.last_name,
                          a.user_id,
                          max(create_date) over (partition by a.user_id, a.loadid) as max_create_date
          from CLAL_LOANCALC_DET a,
               loan_Calculator b,
               bv_user_profile c,
               bv_mr_user_profile d
          where b.loanid = a.loanid
          and   c.NET_USER_NO = a.resp_id
          and   d.user_id = c.user_id
          and   a.is_partner is null
          and   a.create_date between
                TO_DATE('6/3/2008 01:00:00', 'DD/MM/YY HH24:MI:SS') and
                TO_DATE('27/3/2008 23:59:00', 'DD/MM/YY HH24:MI:SS')
    where create_date = max_create_date
    order by create_date

  • Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hi. I have an iPhone 4s. The music doesn't play when I connect it to my car stereo. It used to play previously but stopped playing all of a sudden. My phone is getting charged when I cut it to the USB port. Please help with this. The iOS is 6.1.3.

    Hello Priyanks,
    I found an article with steps you can take to troubleshoot issues with an iPhone not connecting to your car stereo:
    iOS: Troubleshooting car stereo connections
    http://support.apple.com/kb/TS3581
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • My "fn" button is stuck on only revealing mission control in Lion. With this problem none of my "f" keys will work nor can I hold "fn" and delete to delete text in opposite direction. Can someone please help with this?

    My "fn" button is stuck on only revealing mission control in Lion. With this problem none of my "f" keys will work nor can I hold "fn" and delete to delete text in opposite direction. Can someone please help with this?

    Following the fix here worked for me:
    https://discussions.apple.com/message/15680566#15680566
    except my plist file was in ~/Library instead of /Library.
    -Scott

  • Can any one help with this query please

    I have a table something as below
    Things_t
    Things Characteristic Char Value
    Item 1 Colour Red
    Item 1 Packaging
    Item 2 Shape Square
    Item 2 Brand Spunk
    Now i want to reterive an item with none of its char values as Null. Using the query “ select distinct things from things_t where char value is Null ” will fetch the item 1 also together with item 2. i want to fetch a record from thing for which none of the char values are Null such as Item 2. Can you please help me with this query.

    Try this:
    WITH t AS
    (SELECT 1 item_id, 17436 chr_id, 14225034 chr_val_id FROM dual UNION
    SELECT 1 item_id, 39 chr_id, 14276173 chr_val_id FROM dual UNION
    SELECT 1 item_id, 17774 chr_id, NULL chr_val_id FROM dual UNION
    SELECT 1 item_id, 265 chr_id, 20502978 chr_val_id FROM dual UNION
    SELECT 1 item_id, 16978 chr_id, 797233 chr_val_id FROM dual UNION
    SELECT 1 item_id, 13092 chr_id, 5666917 chr_val_id FROM dual UNION
    SELECT 1 item_id, 15228 chr_id, 1209758 chr_val_id FROM dual UNION
    SELECT 2 item_id, 112 chr_id,  12705342 chr_val_id FROM dual UNION
    SELECT 2 item_id, 6945 chr_id, NULL chr_val_id FROM dual UNION
    SELECT 2 item_id, 70 chr_id, 12597376 chr_val_id FROM dual UNION
    SELECT 2 item_id, 16832 chr_id, NULL chr_val_id FROM dual UNION
    SELECT 2 item_id, 7886 chr_id, 9588619 chr_val_id FROM dual UNION
    SELECT 2 item_id, 6986 chr_id, 2659351 chr_val_id FROM dual UNION
    SELECT 3 item_id, 9531 chr_id, 8910943 chr_val_id FROM dual UNION
    SELECT 3 item_id, 9798 chr_id, 8717531 chr_val_id FROM dual UNION
    SELECT 3 item_id, 17446 chr_id, 12266441 chr_val_id FROM dual UNION
    SELECT 3 item_id, 4830 chr_id, 13683090 chr_val_id FROM dual UNION
    SELECT 3 item_id, 9518 chr_id, 834772 chr_val_id FROM dual UNION
    SELECT 3 item_id, 11031 chr_id, 20233753 chr_val_id FROM dual UNION
    SELECT 3 item_id, 12564 chr_id, 2282478 chr_val_id FROM dual)
    SELECT DISTINCT item_id
    FROM   t
    MINUS
    SELECT DISTINCT item_id
    FROM   t
    WHERE  chr_val_id IS NULLOr this:
    SELECT item_id
    FROM  (SELECT   item_id,
                    MIN(NVL(chr_val_id, -1)) min_chr_val_id
           FROM     t
           GROUP BY item_id)
    WHERE  min_chr_val_id != -1Edited by: lee200 on Oct 15, 2012 9:22 AM

  • Please help with tricky query

    I need help with SQL query (if it can be accomplished with query at all).
    I'm going to create a table with structure similar to:
    Article_Name varchar2(30), Author_Name varchar2(30), Position varchar2(2). Position field is basicly position of an article author in the author list, e.g. if there is one author, his/her position is 0, if 2, then 1st author is 0, second is 1, etc.
    Article_Name Author_Name Position
    Outer Space Smith 0
    Outer Space Blake 1
    How can I automate creation of Position, based on number of authors on the fly? Let's say I have original table without Position, but I want to create a new table that will have this information.
    Regards

    If you have an existing table whose structure doesn't tell you what position the author is in, what's the algorithm you'd use to determine who was the first author, the second author, etc? If you issue a select query on a table without providing an "order by" clause, Oracle makes no guarantees about the order in which it retrieves rows.
    As an aside, why would you store position number in a varchar2 field? If it's a number, it ought to be stored as a number.
    Justin

  • Please help me this query

    Plz help me this query:
    Create a query that displays the employees last name and indicates the amounts of their annual salaries with *. Each * signifies a thousand $'s.
    EG. If the salary of an employee with last name king is 2000 then it should appear as follows:
    King **
    2 (*) for 2 thousand.
    Thanks in advance

    Hi,
    I was able to solve this query on my own. For those who might face a problem in future the solutionto it is:
    SELECT rpad(last_name, length(last_name) + (salary/1000), '*') AS employee_and_their_salaries
    FROM employees;
    Thanks

  • Please help with some query

    hello all!
    please, help me again.
    we have a foreign key discrepancy and my task is to create a view which will show the 3 aspects.
    Let's we have 3 schemas: A - good (which means that i will compare WITH A, source)
    B and C are bad (which mean that I will checking this schemas).
    So, i need to obtain:
    1) FK that DO NOT exist in B&C and do exist in A
    2) FK that DO exist in bad schemas (B&C) but DO NOT exist in good schema (A)
    3) FK's that exist in both (A&B, A&C) schemas on the SAME TABLE, have THE SAME CONSTRAINT_NAME but are on the DIFFERENT columns.
    the first and second I seem to be done through the
    select CONSTRAINT_NAME, TABLE_NAME, STATUS from dba_constraints where owner='PRIV_MD' and CONSTRAINT_TYPE='R' and CONSTRAINT_NAME
    2 NOT IN (select CONSTRAINT_NAME from dba_constraints where owner ='MSA_MD'); (to get the second task we just reversing owners in query and subquery)
    query. but the third one is really pain in my back. i have a query:
    SELECT a.column_name, b.column_name FROM dba_cons_columns a, dba_cons_columns b, dba_constraints c, dba_constraints d
    WHERE c.CONSTRAINT_TYPE='R'
    AND a.CONSTRAINT_NAME = b.CONSTRAINT_NAME
    AND a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    AND b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    AND a.owner = 'PRIV_MD' AND b.owner = 'MSA_MD';
    which runs hours and returns million of rows with the two columns with the same names... but if i'm adding
    AND a.column_name != a.column_name (i'm not sure it's a correct syntax)
    line it returns "no rows selected"
    please, help me obtain it, i'm fighting already the second day..
    (please, don't be angry, i'm just learning and this is my first task on my work...)

    This is basically just a UNION ALL (the constraint columns from both schemas)
    MINUS what exists in both (the INTERSECTion)
    I made it a little more complicated so you could see in which schema the column is used. You could use exactly the same approach for your questions 1 and 2 also.
    SELECT * FROM
    (SELECT a.column_name,c.constraint_name,'salive' schema_containing
    FROM dba_cons_columns a
    INNER JOIN dba_constraints c ON a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    WHERE a.owner = 'SALIVE' and c.constraint_type = 'R'
    UNION ALL
    select b.column_name,d.constraint_name,'satest'
    FROM dba_cons_columns b
    INNER JOIN dba_constraints d ON b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    WHERE d.CONSTRAINT_TYPE='R' AND b.owner = 'SATEST') u
    WHERE NOT EXISTS
    (SELECT *
    FROM
    (SELECT a.column_name,c.constraint_name
    FROM dba_cons_columns a
    INNER JOIN dba_constraints c ON a.CONSTRAINT_NAME = c.CONSTRAINT_NAME
    WHERE a.owner = 'SALIVE' and c.constraint_type = 'R'
    INTERSECT
    select b.column_name,d.constraint_name
    FROM dba_cons_columns b
    INNER JOIN dba_constraints d ON b.CONSTRAINT_NAME = d.CONSTRAINT_NAME
    WHERE d.CONSTRAINT_TYPE='R' AND b.owner = 'SATEST') i
    WHERE u.column_name = i.column_name and u.constraint_name = i.constraint_name)

  • Can anyone help with this query

    create table customer(
    customer_email varchar(100) not null
    ,cust_id int not null
    ,constraint pk__customer primary key clustered(cust_id)
    Please help ASAP
    create table purchase (
    purchase_id int not null identity(1,1)
    ,cust_id int not null references customer(cust_id)
    ,product_name varchar(200) not null
    ,amount int not null
    ,constraint pk__purchase primary key clustered (purchase_id)
    Write a query that returns one row per customer with the following columns. Don't forget about customers with no purchases.
    customer_email
    qty of purchase
    sum of purchase amount

    Homework deadline looming?
    This will work in versions of Oracle from 9 up, and in all versions of Sybase/ SQL Server (which you seem to wnat based on the CREATE TABLE syntax).
    SELECT customer_email, COUNT(*) number_purchaes, SUM(amount) total_purchases
    FROM customer c
         LEFT OUTER JOIN purchases p ON c.cust_id = p.cust_id
    GROUP BY customer_emailTTFN
    John

  • Please help with this issue "To Run a SSIS Package outside of Server Data Tools You must install Drived Column of Integration sercvies of higher" From C# app

     i have searched all over the google and here on MSDN(I have read all the threads related to my problem ) , i am new to SISS and doing my clg project ,
    I have this package which loads data from  dim tables to a fact table , my Package runs without any problem in BIDS (2012)
    I have installed SQl Server integration services on SQL and service is also running in services.msc,
    the problem comes when i execute my package using my C# application i am using MSDN Method to execute a SSIS package programmatically given here.
    "http://msdn.microsoft.com/en-us/library/ms136090.aspx"
    For loading my FactTable i have used a Derived columns  and some lookups , 
    Now if i don't use derived columns and looks ups and just use source and destination component then my package runs fine from my C# application but if i use derived columns or looks ups etc it gives the following error
    "Error in Microsoft.SqlServer.Dts.Runtime.TaskHost/SSIS.Pipeline: To Run a SSIS package outside of SQL Server Data Tools you must Install Derived Column of Integration services of higher"
    I am searching and trying to resolve this issue from previous 2 days but without any luck please help or guide me what is solution to this problem ,,i will be very thankful
    I have also found that integration services that are running on my system have version  10.0
    but the BIDS have version Version 11.0.3402.0
    IS this causing problem ?  if yes then what i have to do  ?

    Hi BlaxButt,
    The package is developed in SSDT installed by SQL Server 2012, so it is a SSIS 2012 package. However, the Integration Services you have installed is SQL Server 2008 R2 version. To run the package outside SSDT, you need SSIS 2012 installed. The reason why
    the package runs fine with only Source and Destination components is that such a simple package can be executed by the DTExec utility installed by SQL Server 2012 Data base Engine or Client Tools (SQL Server Import and Export Wizard). To run a package that
    uses other tasks/components outside SSDT/BIDS, the SSIS runtime is also required except the DTExec utility. To obtain the SSIS 2012 runtime, we have to install SSIS 2012 on the server where the package runs.
    Reference:
    http://stackoverflow.com/questions/19989099/getting-error-running-ssis-package-on-non-ssis-server
    Regards,
    Mike Yin
    TechNet Community Support

  • I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect to my MacBook it erases everything on had on there. Can someone please help with this problem?

    I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect it to my MacBook it erases everything I had save on the hard drive. Can someone please help me with this problem? I am super tired of having to put all of my movies and music on the hard drive just to have it erased again. The products I am using are WD 4TB My Book and 2 TB My Passport external hard drives. When it happens, there is always an icon that reads, EFI, along with the My Book icon. Thank you for your assisstance.

    dwgar1322 wrote:
    I have just started using WD external hard drives, I use it to save my movies and music on. On more than one occasion, when I connect it to my MacBook it erases everything I had save on the hard drive. Can someone please help me with this problem? I am super tired of having to put all of my movies and music on the hard drive just to have it erased again. The products I am using are WD 4TB My Book and 2 TB My Passport external hard drives. When it happens, there is always an icon that reads, EFI, along with the My Book icon. Thank you for your assisstance.
    Yes, you have WD software installed  REMOVE IT !! 
    WD has warned its customers about their huge mistake that their software doesnt work on Mavericks and causes data loss.
    (also dont use WD drives anymore)
    Read all about it here:
    https://discussions.apple.com/thread/5475136?start=255&tstart=0
    See their website on removing the destructive WD software here:
    http://community.wd.com/t5/External-Drives-for-Mac/External-Drives-for-Mac-Exper iencing-Data-Loss-with-Maverick-OS/td-p/613775
    Western Digital External Hard Drives Experiencing Data Loss On OS X Mavericks
    http://www.cultofmac.com/252826/western-digital-external-hard-drives-experiencin g-data-loss-on-os-x-mavericks/

  • Please help with a query

    select * from testme;
    NAME VAL
    A 1
    A 2
    A 3
    B 1
    B 2
    B 3
    C 1
    C 2
    I want to get the maximum of name and the maximum of corresponding name's value.
    ie., the answer should be
    Name VAL
    C     2
    Please help me with the query.
    Thnx

    SQL> create table testme
      2  as
      3  select 'A' name, 1 val from dual union all
      4  select 'A', 2 from dual union all
      5  select 'A', 3 from dual union all
      6  select 'B', 1 from dual union all
      7  select 'B', 2 from dual union all
      8  select 'B', 3 from dual union all
      9  select 'C', 1 from dual union all
    10  select 'C', 2 from dual
    11  /
    Tabel is aangemaakt.
    SQL> select max(name) name
      2       , max(val) keep (dense_rank last order by name) val
      3    from testme
      4  /
    NAME VAL
    C      2Regards,
    Rob.

  • Please help with this error: "Your request could not be completed because of a disk error"

    So photoshop cs6 was working fine a few weeks ago. After not using it for about 2 weeks, I try opening a RAW file and I get this error every time. JPGs open and work fine. I have extensively searched on the internet for solutions and have tried everything such as: disk checking, deframgenting, playing around with photoshop preferences, deleting temp files, resetting preferences, clearing disk space. I have assigned two hard drives for photoshop, one with 16 GB free and the other with 8 GB free. I am getting very frustrated. Please help!

    mistahbo1 wrote:
    …I have assigned two hard drives for photoshop, one with 16 GB free and the other with 8 GB free. I am getting very frustrated. Please help!
    That's woefully inadequate for scratch file space.
    The rule of thumb I follow says to figure on 50 to 100 times the size of your largest file ever multiplied by the number of files you have open.  I have seen the scratch file exceed 300 GB once, an admittedly rare occurrence, but it often exceeds 200 GB when stitching large panoramas and the like.
    Additionally, if either one those two drives you mention with "16 GB free and the other with 8 GB free" happened to be your boot drive, you'd be in a heap of trouble because neither one of those drives has nearly enough space to accommodate the swap files of the OS and Photoshop's scratch.
    As an example—and stressing that I'm aware that others have even more scratch space than I do—I keep two dedicated, physically separate hard drives as my primary and secondary Photoshop scratch disks and a lot of GB free on my boot drive for the OS.  I have 16 GB of RAM installed:

  • Please help with chart query

    Hello, i am trying to display a line chart, for some sales data.
    I want a line (series) for each product, X axis should be the years in the data
    (2007, 2008, 2009 there is no more data than these years)
    The plan is to eventually use a "Function Returning SQL Query" to get dynamic series.
    But i tried to hardcode 2 lines for 2 products first to try it out.
    I used this query in SQL Workshop > SQL Commands
    to view the data i want and it works correctly
    Query1:
    SELECT product.major_brand, timeperiod.year, SUM(sales_fact.euro_sales) AS sales
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.year
    ORDER BY product.major_brand, timeperiod.year ASCI have tried the following query for the chart but it will show 2 flat lines
    with the value 0 for each year.
    Query2:
    SELECT NULL
          ,timeperiod.year
          ,SUM(decode(product.major_brand, 'BELCINO', sales_fact.euro_sales, 0)) "BELCINO"
          ,SUM(decode(product.major_brand, 'BIORGANIC', sales_fact.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact
    INNER JOIN product ON sales_fact.product_id = product.product_id
    INNER JOIN timeperiod ON sales_fact.timeperiod_id = timeperiod.timeperiod_id
    GROUP BY product.major_brand, timeperiod.yearThanks for reading,
    Any help is appreciated!
    Edited by: 908157 on 15-jan-2012 5:22
    Edited by: 908157 on 15-jan-2012 5:22

    Thanks Jeff for the quick response,
    I have looked at the examples, tried some things
    and found out that my GROUP BY was the problem.
    Apperantly i only have to GROUP BY on year and not also on product.
    I dont fully understand why yet,
    i guess the query gets parsed and translated to 2 queries, one for each line, that makes sense
    This is the query that worked for me:
    SELECT NULL
          ,t.year
          ,SUM(decode(p.major_brand, 'BELCINO', s.euro_sales, 0)) "BELCINO"
          ,SUM(decode(p.major_brand, 'BIORGANIC', s.euro_sales, 0)) "BIORGANIC"
    FROM sales_fact s, product p, timeperiod t
    WHERE s.product_id = p.product_id
    AND s.timeperiod_id = t.timeperiod_id
    GROUP BY t.year
    ORDER BY t.yearThanks again!

  • Please help with the query (INSERT RETURNING BULK COLLECT INTO)

    I am trying to write a query inside the C# code where I would insert values into a table in bulk using bind variables. But I also I would like to receive a bulk collection of generated sequence number IDs for the REQUEST_ID. I am trying to use RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs clause where :REQUEST_IDs is another bind variable
    Here is a full query that use in the C# code
    INSERT INTO REQUESTS_TBL(REQUEST_ID, CID, PROVIDER_ID, PROVIDER_NAME, REQUEST_TYPE_ID, REQUEST_METHOD_ID, SERVICE_START_DT, SERVICE_END_DT, SERVICE_LOCATION_CITY, SERVICE_LOCATION_STATE, BENEFICIARY_FIRST_NAME,
    BENEFICIARY_LAST_NAME, BENEFICIARY_DOB, HICNUM, CCN, CLAIM_RECEIPT_DT, ADMISSION_DT, BILL_TYPE,
    LANGUAGE_ID, CONTRACTOR_ID, PRIORITY_ID, UNIVERSE_DT, REQUEST_DT, BENEFICIARY_M_INITIAL,
    ATTENDING_PROVIDER_NUMBER, BILLING_NPI, BENE_ZIP_CODE, DRG, FINAL_ALLOWED_AMT, STUDY_ID, REFERRING_NPI)
    VALUES
    (SQ_CDCDATA.NEXTVAL, :CIDs, :PROVIDER_IDs, :PROVIDER_NAMEs, :REQUEST_TYPE_IDs,
    :REQUEST_METHOD_IDs, :SERVICE_START_DTs, :SERVICE_END_DTs, :SERVICE_LOCATION_CITYs,
    :SERVICE_LOCATION_STATEs, :BENEFICIARY_FIRST_NAMEs, :BENEFICIARY_LAST_NAMEs, :BENEFICIARY_DOBs,
    :HICNUMs, :CCNs, :CLAIM_RECEIPT_DTs, :ADMISSION_DTs, :BILL_TYPEs, :LANGUAGE_IDs,
    :CONTRACTOR_IDs, :PRIORITY_IDs, :UNIVERSE_DTs, :REQUEST_DTs, :BENEFICIARY_M_INITIALs,
    :ATTENDING_PROVIDER_NUMBERs, :BILLING_NPIs, :BENE_ZIP_CODEs, :DRGs, :FINAL_ALLOWED_AMTs,
    :STUDY_IDs, :REFERRING_NPIs) RETURNING REQUEST_ID BULK COLLECT INTO :REQUEST_IDs
    However, when I run this query, it gives me a strange error ORA-00925: missing INTO keyword. I am not sure what that error means since I am not missing any INTOs
    Please help me resolve this error or I would appreciate a different solution
    Thank you

    You cannot use (and do not want to in this case) the BULK COLLECT.
    create table for_testing
       the_id      number not null primary key,
       some_data   number
    declare
       l_return_value for_testing.the_id%type;
    begin
      4 
       insert into for_testing
          the_id,
          some_data
       values
          1,
          5
       returning the_id into l_return_value;
       dbms_output.put_line('the return values is ' || l_return_value);
    end;
    20  /
    the return values is 1
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.02
    TUBBY_TUBBZ?Is a simple example. In the future, please use the tags to preserve formatting on your code like i have so it remains readable .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Maybe you are looking for