Returning Mutiple Addresses as a Single Record + current addresses

Hello All,
I have to return students home and dorm addresses as a single record.
Need to go from something like this:
LAST_NAME     FIRST_NAME     ADDY_TYPE   ADDRESS             ZIP
Smith                John             HOME         123 Awesome St     10003
Smith               John               DORM         Oak Quad             10013To this desired format:
LAST_NAME  FIRST_NAME     ADDY_TYPE  ADDRESS         ZIP        ADDY_TYPE     ADDRESS     ZIP
Smith            John      HOME        123 Awesome St  10003   DORM            Oak Quad     10013Also need to get their latest addresses by date.
The database keeps records of every place the students have move from dorm to dorm
and some students permanent residences ("HOME") has changed as well.
Would like to return only one DORM address and only one HOME address
for every student.
So I'm looking at possibly a CASE function to put it on one line/record and a RANK BY() or DENSE_RANK to determine the latest addresses.
Hope I'm making some sense and as always much appreciation for any help. Thanks.

Hi,
user11137889 wrote:
Also need to get their latest addresses by date. Then you must have a column (I'll call it addy_date) that can be used to tell you which is the latest.
The database keeps records of every place the students have move from dorm to dorm
and some students permanent residences ("HOME") has changed as well.
Would like to return only one DORM address and only one HOME address
for every student.
So I'm looking at possibly a CASE function to put it on one line/record and a RANK BY() or DENSE_RANK to determine the latest addresses. I think that's the best way, though if you want only one of each type, then ROW_NUMBER is more appropriate than RANK or DENSE_RANK.
WITH    got_rnum     AS
     SELECT     last_name
     ,     first_name
     ,     addy_type
     ,     address
     ,     zip
     ,     ROW_NUMBER () OVER ( PARTITION BY  last_name
                               ,                    first_name
                         ,             addy_type
                         ORDER BY        addy_date     DESC     NULLS LAST
                       ) AS rnum
     FROM    table_x
--     WHERE     ...          -- Any filtering goes here
SELECT    last_name
,       first_name
,       MIN (CASE WHEN addy_type = 'HOME' THEN address END)     AS home_address
,       MIN (CASE WHEN addy_type = 'HOME' THEN zip     END)     AS home_zip
,       MIN (CASE WHEN addy_type = 'DORM' THEN address END)     AS dorm_address
,       MIN (CASE WHEN addy_type = 'DORM' THEN zip     END)     AS dorm_zip
FROM       got_rnum
WHERE       rnum     = 1
GROUP BY  last_name
,            first_name
;This assumes the combination (last_name, first_name) uniquely identifies a student.
If you'd post CREATE TABLE and INSERT statements for some sample data, then I could test this.

Similar Messages

  • Want to show data from current month & prev month in single record on forms?

    Hello experts,
    i have this requirement:
    Table structure:
    MOnth       Division         totalAmount
    01-apr-2013      1               10000
    01-May-2013    1               20000
    01-apr-2013      2               30000
    01-May-2013    2               50000
    i want to display in forms like
    Form:
    Month  : 01-May-2013
    Month               Division               total               prev_Month          division               total                         dIFFERENCE
    01-May-2013               1              10000                01-Apr-2013               1               20000                        10000
    01-May-2013               2              30000                01-Apr-2013               2               50000                        20000
    I am using two procedure for fetching records for current month and previous month.
    but it will cause problem, if for some division previous month data not present.
    please suggest me some query with which i can fetch current and pre month data in single record.
    Please help me out.
    Thanks
    yash

    I'M NOT SURE BUT TRY IT ............
    select x.mn mnth, x.division, x.totalAmount total, y.mn prev_month,  y.division, y.totalAmount total, (y.totalAmount - nvl(y.totalAmount,0)) difference
    from
      (select month mn, division, totalAmount
      from table_name
      where month = (select max(month)
      from table_name
      ) x,
      (select month mn, division, totalAmount
      from table_name
      where month = (select add_months(max(month),-1)
      from table_name
      ) y
    where x.division = y.division(+)
    MOSTAFIZ MITUL
    DHAKA BANGLADESH

  • Error:  Current provider does not support returning multiple recordsets from a single execution

    Hello,
    The following piece of code which has been working for the
    past five years suddenly started giving me the following error:
    Current provider does not support returning multiple recordsets
    from a single execution
    We have recenlty moved this site to a new server. Could this
    error be related to their CFAdmin settings? Eveything else on the
    site seems to be working fine. Or am I using an outdated tag or
    something?
    Any light in this direction is appreciated, thanks.
    Here's the code:

    There doesn't seem to be anything that seems wrong with the
    code. It might have something to do with the Max Pooled Statements
    or Number of Connections settings in the CF Administrator, but it
    could just as easily have something to do with a setting on the
    database. I would check with your provider.

  • Integrating number of records into a single record

    Hi
    I have a table where we store trainees with certifications, it stores trainees address, id, pass/fail flag, course codes, competetion date and certificate expiration date. WHat I need is to display a single record for each trainee in my query. In this case, what we have currently in the table is we might have 11 certificates for a trainee or 1 or maybe 5 etc. All I need is to display all his information, address, trainee id, courrse code..course code11 in a signle record. Is it possible and how? Please help

    Try this one - it points to the same page and looks like it works:
    Re: How to show the SELECT result in a certain form?

  • How to use execute query For a single record

    Hi All,
    I am working with oracle forms 10g, I have developed a custom form.
    I the form user enter some data and click save in the menu and data get inserted into my table. Inside the insert statement i have hardcoded some values, Once data get inserted i cant able to see that values immediately in my text fields in my form.After requerying i can able to see the changes.
    For example I have a text field called Status, and the field is display only field. At that time of insert i have hardcoded as "INCOMPLETE". Once the user enter the data in the form and click save the data get inserted in to my table but i cant able to see the status, after i requery my form i can able to see the status.
    Here i do multi insert also.
    This is my insert statement
    BEGIN
    First_Record;
    LOOP
    IF :BANK_GUARANTEE_BLK.CHECK_IN_OUT = 'Y'
    THEN
    XXBANK_GUARANTEE_HEADERS.XXBANK_GUARANTEE_INSERT;(this is my package, here i have written my insert statement)
    --Execute_query;
    END IF;
    Exit when :System.Last_Record = 'TRUE';
    Next_Record;
    END LOOP;
    END;
    If user insert only one row and i gave Execute_query to refresh and bring the current data, but when i use execute_query Its brings up all the datas in the table.
    Can any one tell me how to avoid this and how to use execute_query for a single record.
    Thanks &regards
    Srikkanth

    Solved,
    The solution is
    set_block_property('LC_REQ_BLK',ONETIME_WHERE,'LC_PO_NUMBER='||:LC_REQ_BLK.LC_PO_NUMBER);
    go_block('LC_REQ_BLK');
    execute_query;
    Works fine.
    Regards
    Sri

  • How can I add recording time to a single recording not a series recording?

    If I set-up a series recording it allows me to add minutes to the recording time why can't I add time to a single recording? For example if I want to record a single show tomorrow I find it on the guide and hit record. Now I want to add a few minutes on the end of the show because I know it always runs over it's advertised time why can't I add the time? It doesn't gives to extra options for a single recording. The only time I can add time to a single recording is if the show is currently on then it allows me to add time but, not before the show is on. So what good does that do? Comcast allowed me to set-up extra options to a single recording.

    Actually you can.  It's a bit clumsy but what you have to do is go to the DVR menu, select scheduled reordings, select the recording you want to extend, scroll through the menu and you will find an option to modify the start / end time.
    If a forum member gives an answer you like, give them the Kudos they deserve. If a member gives you the answer to your question, mark the answer as Accepted Solution so others can see the solution to the problem.

  • Function Module to convert multiple records into single record and vice-ver

    hi,
    i have a requirement to convert 10 records in an internal table to single record which should be passed
    to a single variable and store in the database.Kindly let me know is there any function module
    which meets my requirement. Also i need to do split one single record to 10 records each of
    say 65 length interval.
    kindly provide me if there is nay functinon module as such.
    I can do with ABAP-OOPS.Please suggest function module.

    I dont think such FM exists, but if you wanna code one it would be simple. Just loop through the internal table, keep concatenating the currently processing record into a long character variable to convert 10 records into one record.

  • Create a Formatted report for a single record

    I am trying to create a report for a single record in a document format instead of row and column format
    For example to list a custome information with list of orders.
    CustomerID ---------------------        Name ------------------------------------
    Address 1 ----------------------         Address 2 ------------------------------
    City --------------------------------        State -------------------------------------
    Zip ---------------------------------
    Order List
    Order 1            Qty          Total Cost
    Order 2            Qty          Total Cost
    We dont have crystal reports setup yet.  I am trying to use report designer...but it is not allowing me to do it.  It creates different group for each row in the query.   Can any one suggest how to do it using report designer or another way in BI 7.0 to create this kind of document.   I want to be able to print this document as pdf or other types.
    Any help is greatly appreciated..
    Thanks

    you can do this both in a formatted report or bex, depending on what kind of an outcome that you are looking for.
    basically, you are first going to present the data in a tabular format and then move the cells around, so the next time you execute the report (analyzer or report designer) it will stay in that format.
    if you are doing it in report designer, first create a query that pulls all required data points and gives them to you in an output as a table.  Then, add that query as a data provider for the formatted report, and you can create additional cells and move the key figures around.  Report designer is a little crude for formatting, but it works
    if you are doing this in BEx Analyzer, then you can do the same thing: create a query and then use the BExGetData formula to pull the required data into required cells
    if you are looking for HIGHLY formatted report (for example you want the output to come out on forms, etc), then you would need to use the Crystal Reports.
    Regardless of what you use for the presentation of the data, the data generation is controlled by the Query itself.  This is one of the tools that SAP is not planning to take away: all the future presentation options will use the query as the data source.
    good luck

  • Reverse auto-population to a shell attribute form/ single record instance BP.

    Hi All,
    I was wondering if anyone had experience in reverse auto-populating data from a BP within a shell to that same shell's attribute form or a single record instance BP like Project Information.
    My use case is that I have 7-10 BP's that gain more definition and have data within in them that changes from phase to phase. This leaves a need for one place with the most current information, which I thought Shell Attributes or Project Information.
    That being said as the information changes in theses 7-10 BP's throughout the life of the project the Shell Attribute form and Project Information should be updated via Reverse auto-population.
    Can anyone tell me if this scenario is possible, or if there is another way that i can achieve this?
    Your help would be appreciated!!!

    Yes, it is possible and fairly simple. Make sure that the DEs from the various BPs that will be passed are on the form of the shell or single instance record.  And make sure that integration is defined for those DEs on the shell or SI record. This is a common mistake, as people forget to define the integration and that is a must for reverse auto-pop.
    Then, on the BPs passing the data, open the form from which they will be passed and look at the properties. Define the reverse auto-pop normally, SI records are always available for this, and shells should be too.
    Sean

  • Need single record for single period. Modify the select query.

    Requirement
    THere are 6 programs for each company for each billing period. If anyof the program for one billing period and period_balance>0 then display outstanding balance YES. if period_balance <=0 for all the programs for one period then outstanding balance=NO
    Below is the query i have used but i have to modify the query to get single record for each period whether outstandignbalance yes or no. Please help to resolve this issue. OR modify the query.
    select distinct B_Billing_key, B_COMPANY_ID company ,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) lastPaymentdate,
    SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,AMOUNT,
    (nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))"Period_Balance",
    decode(sign((nvl(SURCH_AMOUNT,0)+nvl(ADJUST_AMOUNT,0)+nvl(PI_AMOUNT,0))-(nvl(sum(AMOUNT),0))),1, 'Yes'
    ,'No'
    ) outstandingbalance
    p.PROGRAM_NAME_ID programname
    FROM tuff_balance_view,MV_PROG_SURCH S,MV_PAYMENT_HOLDING H,MV_PROGRAM_DICT P where
    b_company_id = 'U-7052-C'
    and B_Billing_key=s.BILLING_KEY
    and S.PROGRAM_KEY = P.PROGRAM_KEY
    and P.PROGRAM_KEY= H.PROGRAM_KEY
    GROUP BY B_Billing_key,B_COMPANY_ID,B_REPORT_PERIOD,SURCH_AMOUNT,ADJUST_AMOUNT,PI_AMOUNT,PROG_SURCH_KEY,
    S.PROGRAM_KEY,p.PROGRAM_NAME_ID,AMOUNT
    order by B_Billing_key desc
    B_Billing_key is the primary key. I am looking for the output only one record for each biling perid. there are 6 programs for each billing period. if any of the program has period balance >0 then outstanding balance should be yes. For sample i am giving 2 programs.
    Actual output from the above
    biling_key company billing period period_balance outstandingbalance programname
    123 xyz January 2011 $4 Yes ABC
    123 xyz January 2011 $-5 NO DEF
    456 xyz February 2011 $-3 NO ABC
    456 xyz February 2011 $- 2 NO DEF
    Need the output as below from the above query. Can you please help to simplify query. If anyof theprogram having outstanding balance for that particular period show the outstandigbalance as yes. Else NO.
    Expected output as below
    company billing period outstandingbalance programname
    xyz January 2011 Yes ABC
    xyz February 2011 No DEF
    Thanks,
    vi

    Hi G,
    With the same query i am gettting outs as NO for all months which is not true. can you pelase look at the following data.
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc
    Actual
    Billing key Billing company periodbalance lastpayment date outs
    110631534073     November 2010     U-7052-C     270          Yes
    110631534073     November 2010     U-7052-C     690          Yes
    110631534073     November 2010     U-7052-C     66          Yes
    110461533197     October 2010     U-7052-C     4740          Yes
    110461533197     October 2010     U-7052-C     27000          Yes
    110461533197     October 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     0     09/13/10     No
    110251532527     September 2010     U-7052-C     0          No
    110251532527     September 2010     U-7052-C     -18     09/13/10     No
    110251532484     August 2010     U-7052-C     0     09/13/10     No
    110251532484     August 2010     U-7052-C     2001     09/13/10     Yes
    110251532484     August 2010     U-7052-C     0          No
    Expectedoutput(need only following columns)
    Billing key Billing company lastpayment date outs
    110631534073     November 2010     U-7052-C               Yes
    110461533197     October 2010     U-7052-C               Yes
    110251532527     September 2010     U-7052-C          09/13/10     No
    110251532484     August 2010     U-7052-C          09/13/10     YES
    By using below query i am getting all output as NO. HOw to modify it.
    SELECT company,
    billing,LastPaymentDate,
    CASE
    WHEN SUM (DECODE (outs, 'YES', 1, 0)) > 0 THEN 'YES'
    ELSE 'NO'
    END Outstanding
    FROM (
    SELECT DISTINCT B_BILLING_KEY,
    to_char(to_date('01/'||trim(substr(B_REPORT_PERIOD,5,2))||'/'||
    trim(substr(B_REPORT_PERIOD,1,4)),'DD/MM/YYYY'),'Month YYYY') Billing,
    B_company_id company,
    sum((nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))) "PeriodBalance",
    Max(to_char(P_RECEIVED_DATE,'MM/DD/YY')) LastPaymentDate,
    decode(sign(
    (nvl(T.B_ORG_SURCH_AMOUNT,0)+nvl(T.B_ORG_PI_AMOUNT,0))-(nvl(T.P_AMOUNT,0))), 1,'Yes','No') Outs
    FROM mv_program_dict P, tuff_balance_view T WHERE
    b_company_id = 'U-7052-C' group by B_REPORT_PERIOD,B_company_id,B_BILLING_KEY,B_ORG_SURCH_AMOUNT,
    B_ORG_PI_AMOUNT,P_AMOUNT
    order by B_BILLING_KEY desc)
    GROUP BY company, billing,LastPaymentDate;
    Note:in the actual out put max(lastpayment date) is returing null values. if there is any date in one billing return that date only remove null example is september. in september it should return only 09/13/10 this date not null date. but if there is no other within one biling then consider that as null example november..
    Thanks,
    v

  • Single record in Export Error log - Essbase Adapter

    We are using FDM to load data to Essbase cubes. Currently in the export.err log file, we are getting the kickout details for a single record at a time. Is there any setting that would give us the entire list of kickouts in a sinlge log?
    Thanks.

    Use a load rule to load a data and you will get a error log listing all errors up to the max errors specified in the Essbase configuration. To use this method from FDM instead of the standard Adapter load check the Enable String Load option in the Adapter configuration settings and specify the name of the Load Rule you wish to use. Personally I would always go for the Load Rule option when loading Essabs from FDM

  • Counting Like Responses in a single record

    Greetings All,
    I have created an online survey consisting of 20 questions
    which are to be answered using yes/no radio buttons. I'd like to be
    able to count the number of yes answers and no answers for a single
    record and display them as a percentage (based on 20, the number of
    questions). Is there a somewhat easy way to do this. The only way I
    could think of is to create 40 queries, a yes and no query for each
    question, pull the recordcount for each query and then use
    mathematic operators to create the percentage. There must be an
    easier way.

    I'm sure you will get a better response than this one, but
    here's an idea.
    One way would be to use a single query to pull the record,
    then use cfset statements to set numerical values (hence to
    additional queries to the database). Like:
    <cfquery name="getrecord" datasource="yourdatasource">
    SELECT *
    FROM table
    WHERE (your query qualification for pulling the record
    </cfquery>
    <cfif q01 = "Yes">
    <cfset qy1 = 1>
    <cfelse>
    <cfset qn1 = 1>
    </cfif>
    <cfq02 = "Yes">
    <cfset qy2 = 1>
    <cfelse>
    <cfset qn2 = 1>
    </cfif>
    ETC... THEN
    <cfset qyestotals = qy1+qy2+ (ETC)>
    <cfset qnototals = qn1+qn2+ (ETC)>
    <cfset yesaverage = qyestotals/20>
    <cfset noaverage = qnototals/20>
    Definitely not brilliant, but it should work on a single
    query.
    If you were showing multiple records, one average at a time,
    use a cfloop over the returned recordset with the above within the
    loop.
    - Mike

  • Search for and edit single record in database

    I am creating a few forms that access an Access database that will be used to enter data into the database.  I am able to open records from the database and scroll through records one at a time and have added features to be able to search for and display a single record.  The problem that I am having  is when I load a single record and then edit that record, I am unable to save any changes made to the record, in other words, the record doesn't update on the database.
    I can add new records and edit records as long as I scroll to them using .next(), .last(), .first(), and .previous() commands; however, when I load a single record I can't figure out how to save changes to that record in the database.

    Ok...so I think i can get it to work by doing something like:
    xfa.sourceSet.DataConnection.open();
    xfa.sourceSet.DataConnection.first();
    var oRecordList = ???????????
    var nCount = oRecordList.length;
    for (var i = 0; i < nCount; i++){
        if (CurrentRecord.rawValue != SearchField.rawValue){
            xfa.sourceSet.DataConnection.next();
    where CurrentRecord is a text field that shows the index of the current record and SearchField is the field where a user enters the record that they are searching for.
    I think I just need to figure out how to count the number of records in the database.  Any ideas?

  • DNS server returns IP addresses even for domain na...

    Like a number of other people I have been looking at the BT Broadband service and have found that there is an issue with the current DNS server. What I / we have found is that the DNS server returns IP addresses even for domain names which should not resolve. See following -
    DNS results wildcarding (?): Warning
    Your ISP's DNS server returns IP addresses even for domain names which should not resolve. Instead of an error, the DNS server returns an address of 92.242.132.15, which resolves to unallocated.barefruit.co.uk.
    There are several possible explanations for this behavior. The most likely cause is that the ISP is attempting to profit from customer's typos by presenting advertisements in response to bad requests, but it could also be due to an error or misconfiguration in the DNS server.
    The big problem with this behavior is that it can potentially break any network application which relies on DNS properly returning an error when a name does not exist.
    The following lists your DNS server's behavior in more detail.
    www.{random}.com is mapped to 92.242.132.15.
    www.{random}.org is mapped to 92.242.132.15.
    fubar.{random}.com is mapped to 92.242.132.15.
    www.yahoo.cmo [sic] is mapped to 92.242.132.15.
    nxdomain.{random}.netalyzr.icsi.berkeley.edu is mapped to 92.242.132.15.
    Moderators could you please investigate this for us.
    Infinidim
    Megadodo Publications
    Ursa Minor Beta
    If you want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side
    If the the reply answers your question then please mark as ’Mark as Accepted Solution’
    Solved!
    Go to Solution.

    RedAmberGreen wrote:
    BT use a Barefruit (which your post seems to suggest) service called 'Error Resolution'.
    http://www.barefruit.com/background/error_resoluti​on.php
    Any DNS that can not get resolved goes via this service and returns a page showing paid adverts and/or links related to what they think you were looking for.
    BT refer to this as 'BT Web Address Help' and can be turned off on an opt-out basis via this link: http://preferences.webaddresshelp.bt.com/selfcare/
    I assume BT's view is this helps improve the user experience and provides some directed help instead of a blank error page.
    Further details: http://www.bt.com/help/webaddresshelp
    Thanks for this RedAmberGreen.
    Infinidim
    Megadodo Publications
    Ursa Minor Beta
    If you want to say thanks for a helpful answer, please click on the Ratings star on the left-hand side
    If the the reply answers your question then please mark as ’Mark as Accepted Solution’

  • Display readonly single record

    Hi
    What's the best way to display a single record in Apex? I need it to be display only (read only). A form or report region doesn't seem to do it.
    So for example something like:
    Customer Details
    First Name: John
    Surname:    Doe
    Address:      23 Anystreet, Anytown
    etc.

    PaulBroughton wrote:
    Sorry one thing I should have said is it is only available on classic reports not interactive ones.
    However interactive reports have Single Row View and Detail View which display similar layouts.

Maybe you are looking for

  • Memory modules hp dv5052ea

    Hi I want o upgrade my memoryto 2gb, nut I noticethe memory module has two small leads attached doesanyone know what they are for, and will they be able to connect to the new module/s? My laptop, is a dv5052ea pavillion,   thanks

  • Attachment for incoming invoice

    Hello All, I achieved to attach an external document to a PO with object id BUS2012. The same method did not work for BUS2081, which is vendor invoice. I use the method CL_BINARY_RELATION=>CREATE_LINK to create attachments. The method does not return

  • Casting an (deserialized) Object as a (custom) subclass.

    Haigh, I'm having trouble casting objects as their subclass. I'll explain, i have a class that fetches a stored serialized object from a Database. i can store the objects no problem. ex. oodb.store(new Machine()); // machine being my custom class tha

  • Is it possible back ground job can transport

    Hi Experts, i have scheduled one job in DEVELOPMENT environment, is it possible to transport DEVELOPMENT environment to TESTING environment. please give the way to transport. Thanks.

  • Facebook download problem

    My Facebook got a problem the time I updated to a newer version, i download the app, it downloads fully then when installing it just writes "error installing", i really miss my Facebook app I really need help