Select one record per person from multiple conditions

Perhaps been staring at this too long and making changes to try and gather the correct population, but can't seem to figure it out at the moment. Trying to determine logic to select one record per person. If person has more than one record would like to choose the record that matches the sequence priority which is:
AND CASE WHEN ac.primary_program_ind = 'N'                                       --Existing Students who have a new program (Continuing Law and added Business)
                               AND ac.academic_period_admitted = ac.academic_period
                               AND ac.student_population <> 'V'
                               AND ac.program is not null THEN 'Y'
                            WHEN ac.primary_program_ind = 'Y'                                        --Visitors (Each term considered new)
                               AND ac.student_population = 'V'
                               AND ac.academic_period_admitted is not null THEN 'Y'
                            WHEN ac.primary_program_ind = 'Y'                                        --Normal Cases
                               AND ac.academic_period_admitted is not null THEN 'Y' --= ac.academic_period THEN 'Y'
                   END = 'Y' Meaning that if the person has records that meet more than one of the above cases, it should choose the record matching the First Case of the case statement. If the records do not meet the first case at all then look to see if it meets the second case and if it does choose that record, etc.
Sample Data:
SELECT 363 AS PERSON_UID, '1875' AS ID, '201140' AS ACADEMIC_PERIOD, '201040' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
UNION SELECT 852, '1962', '201130', '201040', 'GR', '', '', 'Y', 'C', 'Y', 'MS'  FROM DUAL
UNION SELECT 852, '1962', '201140', '201140', 'GR', 'Y', '', '', 'G', 'N', 'MBA' FROM DUAL
UNION SELECT 852, '1962', '201140', '201040', 'GR', '', '', 'Y', 'G', 'Y', 'MS' FROM DUAL
UNION SELECT 659, '1093', '201140', '200840', 'UG', '', '', 'Y', 'T', 'Y', 'BB' FROM DUALSo for the above data on ID '1962', I would like to select the record that has EXIST_NEWPROG = 'Y' and ignore the other rows for that ID. Note:EXIST_NEWPROG, VISITORS, NORMAL I added to sample data, these cols don't actually exist. Put in for easier display purpose to show what case statements are doing. The actual sql statement has many joins and where statements, but hopefully this simplification of the sql will be sufficient to derive a solution.
WITH MULTIROWS AS
SELECT 363 AS PERSON_UID, '1875' AS ID, '201140' AS ACADEMIC_PERIOD, '201040' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
UNION SELECT 852, '1962', '201130', '201040', 'GR', '', '', 'Y', 'C', 'Y', 'MS'  FROM DUAL
UNION SELECT 852, '1962', '201140', '201140', 'GR', 'Y', '', '', 'G', 'N', 'MBA' FROM DUAL
UNION SELECT 852, '1962', '201140', '201040', 'GR', '', '', 'Y', 'G', 'Y', 'MS' FROM DUAL
UNION SELECT 659, '1093', '201140', '200840', 'UG', '', '', 'Y', 'T', 'Y', 'BB' FROM DUAL
select *
from multirows ac
where  CASE WHEN ac.primary_program_ind = 'N'                                       --Existing Students who have a new program (Continuing Law and added Business)
                               AND ac.academic_period_admitted = ac.academic_period
                               AND ac.student_population <> 'V'
                               AND ac.program is not null THEN 'Y'
                            WHEN ac.primary_program_ind = 'Y'                                        --Visitors (Each term considered new)
                               AND ac.student_population = 'V'
                               AND ac.academic_period_admitted is not null THEN 'Y'
                            WHEN ac.primary_program_ind = 'Y'                                        --Normal Cases
                               AND ac.academic_period_admitted is not null THEN 'Y' --= ac.academic_period THEN 'Y'
                   END = 'Y'

Hi,
user1069723 wrote:
Thanks Frank. I've been incorporating your solution and going over the data, (which is why it has taken so long to respond) and am getting closer, however the approach you provided excludes people who have a "RNum" of 2 or 3, but do not have a 1 at all. So people that only have a 2 and 3 OR only have a 2 or only have a 3 would not be captured, but if there is only one record, they would be missed.
Here is another set of records of one person.
SELECT 921 AS PERSON_UID, '8284' AS ID, '201130' AS ACADEMIC_PERIOD, '201030' AS ACADEMIC_PERIOD_ADMITTED, 'UG' AS STUDENT_LEVEL, '' AS EXIST_NEWPROG, 'Y' AS VISITORS, 'Y' AS NORMAL, 'V' AS STUDENT_POPULATION, 'Y' AS PRIMARY_PROGRAM_IND, 'LA' AS PROGRAM FROM DUAL
UNION SELECT 921, '8284', '201140', '201040', 'UG', '', '', 'Y', 'F', 'Y', 'BB'  FROM DUAL
Sorry, I can't reproduce the problem.
If I add the two new rows of sample data that you posted today to the data you posted yesterday, then the query I posted yesterday produces:
PERSON_UID ID   ACADEM ACADEM ST E V N S P PRO      R_NUM
       659 1093 201140 200840 UG     Y T Y BB           1
       363 1875 201140 201040 UG   Y Y V Y LA           1
       852 1962 201140 201140 GR Y     G N MBA          1
       921 8284 201130 201030 UG   Y Y V Y LA           1Io you get the correct output for the original ids?
If I DELETE all the rows where id != 8284 I still get the same results for id=8284.
'm using Oracle 11.1.0.6.0. What version are you running?
Post your exact code, even iof you think you copied it from thsi site without any changes. Perhaps there was some subtle eidting mistake.
I would like to select the record for Academic_Period = 201140 for this person. Is the problem that you're getting the wrong row for id=8284, or that you're not getting any output for id=8284?
Why would you want to get the row with academic_period=201140? (Let's call this row A.) Why don't you want the other row for that person, the one with academic_period=201130? (Let's call this row B.) On both of those rows, primary_program_ind='Y' and academic_period_admitted is not NULL. The only significant difference between those two rows is that student_population='F' on row A, and it's 'V' on row B. Doesn't that mean that row B causes the CASE expression to return 3 ("Normal Case"), while row B makes it return 2 ("Visitor")? Doesn't that mean row B should be preferred to row A?
Then again, perhaps this is just what you mean by saying that "term" is the main factor in deciding which row to select, and that the CASE expreesion ("New Program" before "Visitors", followed by "Normal Cases") is just a tie-breaker.
Based on my understanding of the code you provided, this person is being excluded altogether because they do not have a record that evaluates to rnum = 1.ROW_NUMBER never returns a value of 2 or 3 unless it has already returned a value of 1. (At least that's how it's supposed to work, and I've never heard of any bugs concerning it.)
This record is also complicated because it has two terms, Does "term" mean "academic_period" here?
in all cases, we would want to select the highest term and then if there is still more than one qualifying record, base the "tie breaker" on the cases. Does this make sense or is my explanation still unclear?It's unclear.
Maybe you need to add one more line at the beginning of the analytic ORDER BY clause (the 6th line below):
WITH     got_r_num     AS
     SELECT     m.*
     ,     ROW_NUMBER () OVER ( PARTITION BY  id
                         ORDER BY       
                                         academic_period     DESC,          -- Added
                                         CASE
                                   WHEN  primary_program_ind      = 'N'     --Existing Students who have a new program (Continuing Law and added Business)
                                                   AND   academic_period_admitted      = academic_period
                                                   AND   student_population       != 'V'
                                                   AND   program                is not null
                                        THEN 1
                                                WHEN  primary_program_ind      = 'Y'     --Visitors (Each term considered new)
                                                   AND   student_population      = 'V'
                                                   AND   academic_period_admitted is not null
                                        THEN 2
                                                WHEN  primary_program_ind      = 'Y'     --Normal Cases
                                               AND   academic_period_admitted is not null
                                        THEN 3
                                         END
                       )     AS r_num
     FROM     multirows     m
--     WHERE     ...     -- If you need any filtering, this is where it goes
SELECT     *     -- or list all columns except r_num
FROM     got_r_num
WHERE     r_num     = 1
;

Similar Messages

  • Selecting one record to display from multiple in list

    I have a report that displays all staff names and dates of when they were checked so some staff have mulitple results as they are checked randomly.
    I need the report to only display the most recent check date from the mulitple results but there isnt a set criteria to select from - eg the last one for Joe bloggs within the past 30 days.
    How do i do this?

    Insert a group on {EMPLOYEE_TABLE.SURNAME}
    Now inorder to get the recent date you need to use group selection formula.
    Go to report>selection formula>group--> write the condition like this
    =maximum(,{EMPLOYEE_TABLE.SURNAME})
    Now the results show only the latest dates for each name.
    Regards,
    Raghavendra

  • Best way to generate one record per day from a table with eff/exp dates

    Hi,
    Have a table which has various attributes and an eff and exp date. e.g attributea, 01/05/2012, 16/05/2012
    We wish to create another table from this table to have one record per day. e.g 16 records.
    What is best way to achieve this in OWB ?
    Thanks

    Hi,
    Example if have table
    with following contents
    conversion_rate number(6,4)
    EFFEcTIVE_DATE DATE
    expiration_date date
    example record 1.43, 01/05/2012,16/05/2012
    If want to have another table which instead has 16 records one for each day
    e.g
    1.43, 01/05/2012
    1.43,02/05/2012
    1.43,16/05/2012
    Thoughts on best way to do this.
    Thanks

  • Select one record for the first matching condition only in four where condi

    I need your suggestion to write one tricky SQL query to select only one record from database on the following condition.I explained simple table structure below.I have a table temp with four columns a,b,c,d in it.
    I have to select column d from this temp table based on the following four conditions.If it matches any condition, It should skip other conditions, that's the tricky thing.
    Conditions order is like shown below.
    1) a='argument1' and b='argument2' and c='argument3'(If it matches this condition, it should stop selecting below 3 conditions)
    2) a='argument1' and b='argument2' and c='none'(If it matches this condition, it should stop selecting below 2 conditions)
    3) a='argument1' and b='none' and c='argument3'(If it matches this condition, it should stop selecting below condition)
    4) a='argument1' and b='none' and c='none'(this is last condition)
    If I use OR operator , it matches all of those other conditions too.I never wrote query like this before.
    I greatly appreciate if somebody sheds light on me to start writing this query with a simple suggestion.
    Thanks,
    GD

    This forum might help you out, as they are experienced SQL developers, however, this forum is primarily for queries about the tool, SQL Developer. I recommend you post this on the SQL & PL/SQL forum where they focus on these queries:
    PL/SQL
    Sue

  • Isd there a way to have mail use more than one address per person from the address book?

    Have a group in address book and some of the records have more than one email address. Is there a way to have mail use both addresses or do I need to have an individual record for each email I want to send to?

    This article seems to describe a way to do what you want.

  • HOW TO PRINT ONE RECORD PER ONE PAGE

    Hi I have report , with two queries. Each query has one group with the same data. lets say the queries are Q1 and Q2. The Groups are with column DeptNo, and DeptNo1 both pointing to the same column DEPTNO. Now I want to design it in such a manner that it shoudl print each group , one record per page, but same group on the same page. For Example
    ON PAGE 1
    DpetNo 10
    Emp1
    Emp2
    Emp3
    DeptNo1 10
    Emp1
    EMp2
    Emp3
    ON PAGE 2
    DeptNo 20
    Emp4
    Emp5
    DeptNo1 20
    Emp4
    Emp5
    ON PAGE 3
    DeptNo 30
    Emp6
    Emp7
    Emp8
    DeptNo1 30
    Emp6
    Emp7
    Emp8
    How the lay our will be ? What will be the conditions. I can set the property in each group to print one record per page. But how to make it so that it will print like above.
    Thanks
    FEROZ

    Hi Feroz,
    You can create a query Q0 to return DeptNo 10, DeptNo 20..... and make it as the parent of Q1 and Q2. Then you can print one dept per page.
    Regards,
    George

  • How to pivot horizontally Author names, and group by Book title. One row per book with multiple authors

    I have 3 tables - Book, Author, BookAuthorReference
    A book can have multiple authors, and when I do straight query I get multiple rows per book
    SELECT <columns>
    FROM Book b, Author a, BookAuthorReference ba
    where ba.BookId = b.BookId and
    ba.AuthorId = a.AuthorId
    I want to get the results as ONE row per book, and Authors separated by commas, like:
    SQL 2008 internals book    Paul Randal, Kimberly Tripp, Jonathan K, Joe Sack...something like this
    Thank you in advance

    This can by done by straying into XML land. The syntax is anything but intuitive, but it works. And moreover, it is guaranteed to work.
    SELECT b.Title, substring(a.Authors, 1, len(a.Authors) - 1) AS Authors
    FROM   Books b
    CROSS  APPLY (SELECT a.Author + ','
                  FROM   BookAuthorReference ba
                  JOIN   Authors a ON a.AuthorID = ba.AuthorID
                  WHERE  ba.BookID = a.BookID
                  ORDER  BY ba.AuthorNo
                  FOR XML PATH('')) AS a(Authors)
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Select single record per distinct type

    My test table is shown below, I needed to return just ONE invoice for each distinct prov_type
    PROV_TYPE INVOICE
    E 111
    E 222
    E 333
    AL 444
    I could use: SELECT distinct prov_type,
    min(invoice)
    FROM test_table
    Yields (one invoice per prov_type):
    Prov_type Invoice
    E 111
    AL 444
    But to extend this, how would I get the same result when
    there are more than just the 2 columns (prov_type and invoice)?
    Example data (selected from numerous tables):
    PROV_TYPE INVOICE SOME_DATES SCHEDULE
    E 111 JUNE 1 40A
    E 222 JUNE1 7A-C
    E 333 MAY 1 20C
    AL 444 JULY 1 7C-R
    I'm trying to select ONE invoice example of
    each prov_type.
    Is there any way to write something to
    get one record of each type of prov_type?....without having to execute the
    underlying where clause twice (once to get the distinct prov type and min
    invoice, and one to get the rest of the data for the invoice???)? I'm wondering this
    because the underlying where clause to get the above data set could be slow.
    I keep thinking there should be some way to select the above data set, and
    then somehow use a subquery or rownum or count(*) or something else to pick and choose the
    records I want from this set.
    Also, I have something similar to this where I select a bunch of data, and I
    want one record where a type column = R and one record where the same type
    column is NOT R. Same idea.. is there any way to select the "bunch of
    data" one time and manipulate the result set? Or do I have to:
    SELECT a_bunch_of_data
    FROM a_bunch_of_tables
    WHERE a_bunch_of_conditions
    AND the_type = 'R'
    AND rownum < 2
    UNION
    SELECT a_bunch_of_data (AGAIN)
    FROM a_bunch_of_tables (AGAIN)
    WHERE a_bunch_of_conditions (AGAIN)
    AND the_type <> 'R'
    AND rownum < 2

    Using PL/SQL AND/OR Dynamic SQL can simplify this. If your requirement
    is strictly SQL however, and your main goal is not to have to join
    anything else to your view, one (tricky) way would involve the following:
    1. get the data length of each needed column (except the key column) from the table definition.
    2. convert each of these column into character type, left padded to its data length
    3. concatenate these columns, with the target column in the front (e.g. Invoice Number)
    4. Apply the group function on the concatenated string, grouping by the key column.
    5. parse the string back
    This shouldn't be bad if you have to set it up only once!
    Note: for the second problem, you can use the same technique, with:
    GROUP BY DECODE(the_type,'R','R','Not R')
    CREATE TABLE test_table (
    PROV_TYPE VARCHAR2(10),
    INVOICE NUMBER,
    SOME_DATE DATE,
    SCHEDULE VARCHAR2(20),
    some_num_field NUMBER(5,3)
    INSERT INTO test_table VALUES('E',111,TO_DATE('JUN 1','MON DD'),'40A',12.123);
    INSERT INTO test_table VALUES('E',22,TO_DATE('JUN 1','MON DD'),'7A-C',3.04);
    INSERT INTO test_table VALUES('E',333,TO_DATE('MAY 1','MON DD'),'20C',1.4);
    INSERT INTO test_table VALUES('AL',444,TO_DATE('JUL 1','MON DD'),'7C-R',9);
    INSERT INTO test_table VALUES('Z',9,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
    INSERT INTO test_table VALUES('Z',123,TO_DATE('JUL 1','MON DD'),'7C-R',12.123);
    INSERT INTO test_table VALUES('Z',999,TO_DATE('JUL 1','MON DD'),'7C-R',99.999);
    SELECT
    PROV_TYPE,
    TO_NUMBER(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    1,38)) invoice,
    TO_DATE(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+1,14),'YYYYMMDDHH24MISS') some_date,
    LTRIM(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+14+1,20)) schedule,
    TO_NUMBER(SUBSTR(
    MIN(LPAD(invoice,38) &#0124; &#0124; TO_CHAR(some_date,'YYYYMMDDHH24MISS') &#0124; &#0124;
    LPAD(schedule,20) &#0124; &#0124; LPAD(some_num_field,39)),
    38+14+20+1,39)) some_num_field
    FROM test_table
    GROUP BY prov_type
    /null

  • JDBC to IDOC Scenario - select data in jdbc based on multiple conditions

    Hello
         I have a JDBC to IDOC Scenario. I have to select the records in JDBC based on different conditions each time. For example I have to select based on company code '1000' and Employee claasification 'E1' and date range. After I post these records in SAP again I want to select other records for some other company code '2000' and different business area and different dates. Basically I want to extract data multiple times based on different conditions.
    Hiow do I achieve this?
    Another question is in the JDBC to IDOC scenario since the sender adapter is JDBC and the sender adapter polls depending on the duration of time ( say 60 secs ) in the adapter once after I extract the data based on a condition how do I control in such a way that the same data is not extracted again.
    Thanks
    Naga

    Hi Naga,
    I have to select the records in JDBC based on different conditions each time. For example I have to select based on company code '1000' and Employee claasification 'E1' and date range. After I post these records in SAP again I want to select other records for some other company code '2000' and different business area and different dates. Basically I want to extract data multiple times based on different conditions.
    -->
    Such requirements cant be handle through select query of the sender...but you can handle this in the message mapping area.....you can fire a select query in the database to pick up records in a batch of 10K (do not keep any condition on this except for sorting). After the records come into PI you can send the message to your target based on the unique combination of "Company code+ Employee clasification + date range" handling this in the message mapping.
    Another question is in the JDBC to IDOC scenario since the sender adapter is JDBC and the sender adapter polls depending on the duration of time ( say 60 secs ) in the adapter once after I extract the data based on a condition how do I control in such a way that the same data is not extracted again.
    You can use the N--> C logic
    The data records that you pick have a corresponding control table i assume. There should be a field STATUS where the initial status of record should be N.
    After you pick the records this status should be made C so that only those records present in the database with status = N are picked up.
    Mention the condition Status = N in the select query.
    Thanks
    Dhwani

  • SapScript is displaying one record per page...

    Hi friends,
    I am getting a problem in scripts.
    when i am displaying multiple records in the main window it is displaying a single record per each page, like if i have 20 records it is displaying 20 pages and in every page one record
    how to resolve this
    plz assist me
    is there any wrong in tagcolumn i.e. / , /: , *
    how i have to maintain them
    Edited by: Alvaro Tejada Galindo on Feb 22, 2008 6:15 PM

    Kindly check ou script & program i think somewhere new-page is written. that'why each record is printing on new page.
    anya

  • HELP I am doing a Data Merge and It is only giving me one record per page!

    I really need help here.  I am doing a data merge and have selected the options for doing multiple records per page but instead it is merging everything to it's own page.  Can someone tell me what I am missing?

    Why do you say you can't do a multiple record merge to a table?
    I've never had any trouble putting placeholders into a table. It's the way I do most of the datamerge that I work with.
    My mistake… I was confused with the script, and I must confess I had never tried (until now) to use tables as placeholders, but it works.
    My apologies for this uncorrect answer

  • Select one record attempt

    I have a form in CF 8 that lists several records depending on
    the query results.
    Each time I hit the select button it goes to the action page
    (second.cfm) and all the records show even though I just selected
    for one record.
    Here is my form:
    <FORM ACTION="second.cfm" METHOD="POST">
    <TABLE WIDTH="600" BORDER="1" ALIGN="CENTER">
    <TR>
    <TH align=left>City</TH>
    <TH align=left>State</TH>
    <TH align=left>County</TH>
    <TH align=left>SELECT ONLY ONE</TH>
    </TR>
    <CFOUTPUT QUERY="getMailingList">
    <TR>
    <TD align=left>#City#</</TD>
    <TD align=left>#State#</td>
    <TD align=left>#County#</TD>
    <TD align=left><INPUT TYPE="Submit"
    value="SELECT"></TD>
    </TR>
    </CFOUTPUT>
    <tr>
    <td colspan="8">
    </td>
    </tr>
    </TABLE>
    </FORM>
    My second.cfm page:
    <cfoutput>
    #form.City#<br>
    #form.State#<br>
    #form.County#
    </cfoutput>
    Even though I select one selection (submit) for the specific
    record I always get all the records.
    Please advise how to make this work where I hit the select
    button and it should give me the one record I selected to show up
    in the second.cfm page.

    The form code you posted does not contain anything resembling
    an input or select in which you can specify what you want.

  • How do I select one record when working with image data sets?

    David Powers had an example with creating spry data sets and using the filename in the database linked to images in the local files as data sources.  The pages shows the images with the specified information requested, however all of the images display with their content.  I want to pull an individual record with the image and content. HELP!
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    $maxRows_rs_getPhoto = 10;
    $pageNum_rs_getPhoto = 0;
    if (isset($_GET['pageNum_rs_getPhoto'])) {
      $pageNum_rs_getPhoto = $_GET['pageNum_rs_getPhoto'];
    $startRow_rs_getPhoto = $pageNum_rs_getPhoto * $maxRows_rs_getPhoto;
    mysql_select_db($database_gepps1_db, $gepps1_db);
    $query_rs_getPhoto = "SELECT last_name, first_name, personal_bio, file_name, width, height FROM mem_profile";
    $query_limit_rs_getPhoto = sprintf("%s LIMIT %d, %d", $query_rs_getPhoto, $startRow_rs_getPhoto, $maxRows_rs_getPhoto);
    $rs_getPhoto = mysql_query($query_limit_rs_getPhoto, $gepps1_db) or die(mysql_error());
    $row_rs_getPhoto = mysql_fetch_assoc($rs_getPhoto);
    if (isset($_GET['totalRows_rs_getPhoto'])) {
      $totalRows_rs_getPhoto = $_GET['totalRows_rs_getPhoto'];
    } else {
      $all_rs_getPhoto = mysql_query($query_rs_getPhoto);
      $totalRows_rs_getPhoto = mysql_num_rows($all_rs_getPhoto);
    $totalPages_rs_getPhoto = ceil($totalRows_rs_getPhoto/$maxRows_rs_getPhoto)-1;
    ?>
    <table width="800" border=" ">
      <tr>
        <td>Image</td>
        <td>thumbnail</td>
        <td>firstname</td>
        <td>lastname</td>
        <td>personal bio</td>
      </tr>
      <?php do { ?>
        <tr>
          <td><img src="<?php echo $row_rs_getPhoto['file_name']; ?>" alt="" width="<?php echo $row_rs_getPhoto['width']; ?>" height="<?php echo $row_rs_getPhoto['height']; ?>"></td>
          <td><img src="<?php echo $row_rs_getPhoto['file_name']; ?>" alt="" width="50" height="35"></td>
          <td><?php echo $row_rs_getPhoto['first_name']; ?></td>
          <td><?php echo $row_rs_getPhoto['last_name']; ?></td>
          <td><?php echo $row_rs_getPhoto['personal_bio']; ?></td>
        </tr>
        <?php } while ($row_rs_getPhoto = mysql_fetch_assoc($rs_getPhoto)); ?>
    </table>
    <?php
    mysql_free_result($rs_getPhoto);
    ?>

    I tried pulling the record by using entered value, but then I would need to create several recordsets.
    It's actually no problem doing that.  Can you explain more what you want the final result of this page to display? You are pulling a recordset of the entire group of photos.  Do you still want that comprehensive recordset on this page?  How many other images do you want?  Are you trying to make a master/detail pair where this page displays only the details for a single image?  See what I mean?

  • Select one record for each member of the group

    Hi,
    am having a table where in i will be having data for so many group members. i need to fetch data for a particular group members whose number of rows of data may be more in numbers (but i want only one row of data for each member of the group)
    here is the query for fetching all rows of data
    select RI.RESOURCE_NAME,TR.MSISDN,TR.ADDRESS1_GOOGLE, TR.MSG_DATE_INFO, FROM TRACKING_REPORT TR, RESOURCE_INFO RI
    WHERE TR.MSISDN IN (SELECT MSISDN FROM RESOURCE_INFO WHERE GROUP_ID ='1' AND COM_ID=2 ) AND RI.MSISDN=TR.MSISDN
    order by MSG_DATE_INFOoutput of this query is...
    >
    ddd     12345          13-Mar-10 19:43:03
    eee     54321     Tamil Nadu, India      13-Mar-10 19:39:48
    ddd     12345          13-Mar-10 19:32:58
    eee     54321     Tamil Nadu, India      13-Mar-10 19:30:07
    ddd     12345          13-Mar-10 19:23:08
    eee     54321     Tamil Nadu, India      13-Mar-10 19:20:14
    fff     98765          13-Mar-10 19:19:22
    ddd     12345          13-Mar-10 19:13:01
    eee     54321     Tamil Nadu, India      13-Mar-10 19:09:50
    ddd     12345          13-Mar-10 19:02:56
    eee     54321     tn,ind      13-Mar-10 18:59:49
    ddd     12345          13-Mar-10 18:53:08
    eee     54321     tn,ind      13-Mar-10 18:49:50
    ddd     12345          13-Mar-10 18:42:56
    eee     54321     tn,ind      13-Mar-10 18:39:50
    ddd     12345          13-Mar-10 18:33:00
    eee     54321     tn,ind      13-Mar-10 18:29:50
    ddd     12345          13-Mar-10 18:22:54
    eee     54321     tn,ind      13-Mar-10 18:19:50
    ddd     12345          13-Mar-10 18:12:56
    eee     54321     tn,ind      13-Mar-10 18:09:50
    ddd     12345          13-Mar-10 18:02:54
    eee     54321     tn,ind      13-Mar-10 18:00:02
    fff     98765     Tamil Nadu, India      13-Mar-10 17:59:26
    fff     98765     Tamil Nadu, India      13-Mar-10 17:54:26
    ddd     12345          13-Mar-10 17:52:56
    eee     54321     tn,ind      13-Mar-10 17:49:50
    fff     98765     Tamil Nadu, India      13-Mar-10 17:49:25
    fff     98765     Tamil Nadu, India      13-Mar-10 17:44:26
    ddd     12345          13-Mar-10 17:42:56
    >
    from this output i want only one latest record for each member(ddd,eee,fff). i.e
    >
    ddd     12345          13-Mar-10 19:43:03
    eee     54321     Tamil Nadu, India      13-Mar-10 19:39:48
    fff     98765          13-Mar-10 19:19:22
    >
    how to modify the query to achieve this...?

    Hi,
    This is not giving the result which i want...
    table is
    CREATE TABLE TRACKING_REPORT
      ID               NUMBER,
      MSISDN           NUMBER(12)                   NOT NULL,
      X                NUMBER(15,8)                 NOT NULL,
      Y                NUMBER(15,8)                 NOT NULL,
      TIME_STAMP       DATE,
      MSG_DATE_INFO    DATE                         DEFAULT sysdate,
      ADDRESS1_GOOGLE  VARCHAR2(400 BYTE),
      ADDRESS2_GOOGLE  VARCHAR2(400 BYTE),
      ADDRESS_MLINFO   VARCHAR2(400 BYTE),
      REQ_ID           VARCHAR2(30 BYTE)
    CREATE TABLE RESOURCE_INFO
      RESOURCE_ID    NUMBER,
      MSISDN         NUMBER,
      RESOURCE_NAME  VARCHAR2(25 BYTE),
      ADDRESS        VARCHAR2(100 BYTE),
      COM_ID         VARCHAR2(20 BYTE),
      ADMIN_ID       NUMBER,
      TIME_STAMP     DATE                           DEFAULT SYSDATE,
      GROUP_ID       NUMBER
    )

  • How to get only one record per machine

    I have this SQL statement that works.
    SELECT 
    cn.Name0 AS [Computer Name],
    cn.Model0 AS [Model],
    cn.Manufacturer0 AS [Manufacturer],
    bios.SerialNumber0 AS [Serial Number],
    rs.Operating_System_Name_and0 AS [OS Type], 
    --ld.FreeSpace0 AS [Free Disk Space],
    --ld.Size0 AS [Actual Disk Size],
    x86.TotalPhysicalMemory0 AS [Total Memory], 
    aa.SMS_Assigned_Sites0 AS [Assigned Site]
    FROM
    v_GS_COMPUTER_SYSTEM cn INNER JOIN v_GS_LOGICAL_DISK ld on cn.ResourceID = ld.ResourceID
    INNER JOIN v_GS_PARTITION gs ON cn.ResourceID = gs.ResourceID
    INNER JOIN v_GS_X86_PC_MEMORY x86 ON gs.ResourceID = x86.ResourceID
    INNER JOIN v_R_System rs ON gs.ResourceID = rs.resourceID
    INNER JOIN v_GS_PC_BIOS bios ON rs.resourceID = bios.ResourceID
    INNER JOIN v_RA_System_SMSAssignedSites aa ON bios.ResourceID = aa.ResourceID
     WHERE 
    cn.Model0 LIKE '%780%' 
    ORDER BY
    cn.Name0
    The problem is whent his runs it returns multiple rows for each serial number/machine it finds.  So I'll have 5 or 6 rows for the exact same machine.  How do I make it only give me 1 row for each serial number/machine?
    mqh7

    ... because you added v_GS_PARTITION gs (which results in multiple rows per resource) and then you are doing the inner join blues.
    This should be better:
    SELECT
     cn.Name0 AS [Computer Name],
     cn.Model0 AS [Model],
     cn.Manufacturer0 AS [Manufacturer],
     bios.SerialNumber0 AS [Serial Number],
     rs.Operating_System_Name_and0 AS [OS Type],
     --ld.FreeSpace0 AS [Free Disk Space],
     --ld.Size0 AS [Actual Disk Size],
     x86.TotalPhysicalMemory0 AS [Total Memory],
     aa.SMS_Assigned_Sites0 AS [Assigned Site]
    FROM
     v_GS_COMPUTER_SYSTEM cn
     -- INNER JOIN v_GS_LOGICAL_DISK ld on cn.ResourceID = ld.ResourceID
      --INNER JOIN v_GS_PARTITION gs ON cn.ResourceID = gs.ResourceID
     INNER JOIN v_GS_X86_PC_MEMORY x86 ON x86.ResourceID = cn.ResourceID
     INNER JOIN v_R_System rs ON rs.ResourceID = cn.resourceID
     INNER JOIN v_GS_PC_BIOS bios ON bios.resourceID = cn.ResourceID
     INNER JOIN v_RA_System_SMSAssignedSites aa ON aa.ResourceID = cn.ResourceID
     WHERE  cn.Model0 LIKE '%780%'
    ORDER BY
     cn.Name0
    Torsten Meringer | http://www.mssccmfaq.de

Maybe you are looking for

  • How to select the business object in ESR and the packages used in SAP 7.1

    Hi I am trying to use the Service interfaces of ESR available in ESA ECC-SE 604 and a few in SAP APPL 6.04. How can we choose the GDT,Business objects or Service interfaces for the requirments? Can we know which package provides which objects like wh

  • Need help in url encode

    hai everybody, my url looks like this http://localhost:8080/examples/title=Project manager&company=XYZ pvt ltd. whats happening is that , since i have space in my url .. all the values after the first space is been truncated..how do i encode the url.

  • HELP: Unintentional audio keyframing

    Hi, I'm not sure how else to describe the problem aside from unintentional audio keyframing, but not that is visible in any individual audio tracks. Here's what's happening. I have a single video clip of someone entering a car.  when he's in the car

  • Performance issue: CALL FUNCTION inside a Loop.

    Hi Friends I have a Performance Issue. That is, inside a loop...endloop a CALL FUNCTION has been used which gets data from another database table. Finally it's appended into another internal table. Please see this :   LOOP AT i_mdkp.     REFRESH lt_m

  • New Login in sql server

    Hi,    When I'm adding new login in SQL server it searches and gives the available AD groups in my domain in the Checknames box. Anyone knows what is the SP called when it searches the Group names from the domain?