Group by and take the Max year Record

Hi,
I have the data as below:
A     B     C     D     E
1     A     ACC     AAA     2008
1     A     BCC     BBB     2007
1     A     CCC     CCC     2009
2     B     ATT     TTT     2004
2     B     BYY     YYY     2009
2     B     CZZ     ZZZ     2006
Here I have to eliminate duplicates using A,B and take the record with max(E)
So output should be:
A     B     C     D     E
1     A     CCC     CCC     2009
2     B     BYY     YYY     2009
Please help me how i can do this.
Thanks in advance
Mahesh

Slightly shorter:
SQL> with t as (
  2   select 1 a, 'A' b, 'ACC' c, 'AAA' d, '2008' e from dual union all
  3   select 1, 'A', 'BCC', 'BBB', '2007' from dual union all
  4   select 1, 'A', 'CCC', 'CCC', '2009' from dual union all
  5   select 2, 'B', 'ATT', 'TTT', '2004' from dual union all
  6   select 2, 'B', 'BYY', 'YYY', '2009' from dual union all
  7   select 2, 'B', 'CZZ', 'ZZZ', '2006 ' from dual
  8  )
  9  --
10  --
11  select a,
12         max(b) keep (dense_rank last order by e) b,
13         max(c) keep (dense_rank last order by e) c,
14         max(d) keep (dense_rank last order by e) d,
15         max(e) e
16    from t
17  group by a
18  /
         A B C   D   E
         1 A CCC CCC 2009
         2 B BYY YYY 2009
2 rijen zijn geselecteerd.Regards,
Rob.

Similar Messages

  • I need to show grouped id and only the max order value for each unique id

    select distinct 
    Table1.id,
    Table1.id +' - '+ Table1.VisitNumber +' : '+ Table1.Priority as UidVisitKey,
    Table1.VisitNumber,
    DATEDIFF(d, [dob],[Visite_dte])/365.25 as Age_On_Visit,
    Table1.Priority,
    Table1.OrderOfVisit,
    Table1.OrderOfVisit + ' - ' + Table1.Notes AS VisitNote, 
    Table1.Visitor_FName,
    Table1.Visitor_SName,
    Table2.dob,
    Table2.sex,
    Table1.Visit_dte,
    into #Temp1
    FROM         Table1 INNER JOIN
                Table2 ON Table1.id = Table2.id
    WHERE Table1.LeaveDate IS NOT NULL 
    and Table1.LeaveDate  between DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)) 
    and DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))) 
    select #Temp1.id, max(#Temp1.[OrderOfVisit]), #Temp1.VisitNote 
    from #Temp1
    group by #Temp1.id, #Temp1.OrderOfVisit, #Temp1.[VisitNote]
    ORDER BY #Temp1.id
    drop table #Temp1
    ---I need to show grouped id and only the max OrderOfVisit for each unique id, and the VisitNote for each OrderOfVisit
    ----------------need help-------------

    Sounds like this
    select distinct
    Table1.id,
    Table1.id +' - '+ Table1.VisitNumber +' : '+ Table1.Priority as UidVisitKey,
    Table1.VisitNumber,
    DATEDIFF(d, [dob],[Visite_dte])/365.25 as Age_On_Visit,
    Table1.Priority,
    Table1.OrderOfVisit,
    Table1.OrderOfVisit + ' - ' + Table1.Notes AS VisitNote,
    Table1.Visitor_FName,
    Table1.Visitor_SName,
    Table2.dob,
    Table2.sex,
    Table1.Visit_dte,
    into #Temp1
    FROM Table1 INNER JOIN
    Table2 ON Table1.id = Table2.id
    WHERE Table1.LeaveDate IS NOT NULL
    and Table1.LeaveDate between DATEADD(mm,-1,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0))
    and DATEADD(ms,-3,DATEADD(mm,0,DATEADD(mm,DATEDIFF(mm,0,GETDATE()),0)))
    select id,OrderOfVisit,VisitNote
    from
    select #Temp1.id, #Temp1.[OrderOfVisit], #Temp1.VisitNote,ROW_NUMBER() OVER (PARTITION BY #Temp1.id ORDER BY #Temp1.[OrderOfVisit] DESC) AS Seq
    from #Temp1
    )t
    WHERE Seq = 1
    ORDER BY id
    drop table #Temp1
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Delete the duplicate and keep the max records.....

    I would like to remove the duplicate records based on columns ID and VAL but keep the max SAL records. ID + VAL is the key in the table and just delete same records by keeping the max sal.
    Note: Eventhough there are two records for the same max SAL, just keep one
    eg
    SQL>  select * from temp_fa;
            ID        VAL        SAL
             1        100         10
             1        100         20
             1        100         20
             2        200         10
             3        300         10
             3        300         30
             4        400         10
             4        400         10
             5        500         10
             5        500         20
             5        500         20
    After deleting the table should looks like
    SQL>  select * from temp_fa;
            ID        VAL        SAL
             1        100         20
             2        200         10
             3        300         30
             4        400         10
             5        500         20

    user520824 wrote:
    I would like to remove the duplicate records based on columns ID and VAL but keep the max SAL records. ID + VAL is the key in the table and just delete same records by keeping the max sal.
    Note: Eventhough there are two records for the same max SAL, just keep one
    eg
    SQL>  select * from temp_fa;
    ID        VAL        SAL
    1        100         10
    1        100         20
    1        100         20
    2        200         10
    3        300         10
    3        300         30
    4        400         10
    4        400         10
    5        500         10
    5        500         20
    5        500         20
    After deleting the table should looks like
    SQL>  select * from temp_fa;
    ID        VAL        SAL
    1        100         20
    2        200         10
    3        300         30
    4        400         10
    5        500         20
    Hi,
    In this script I included sal in the key because it's more safe for you.
            ID        VAL        SAL
             1        100         10
             1        100         20
             1        100         20
             2        200         10
             3        300         10
             3        300         30
             4        400         10
             4        400         10
             5        500         10
             5        500         20
             5        500         20
    --1.Preserve first row from all duplicates
    create table first_duplicate as
    (select distinct val, id, sal
    from temp_fa
    where to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) in
    (select to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) p_key
          from temp_fa
          group by to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal)
             having count(to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal))>1)
    --2.Delete all duplicates
    DELETE  FROM temp_fa
    where to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) in 
         (select to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) p_key
         from temp_fa
         where to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) in
              (select to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) p_key
              from temp_fa
               group by to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal)
                  having count(to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal))>1)
    --3.Add first row from all duplicates
    insert into  temp_fa (val, id, sal)
    select * from first_duplicate;
    --4.Delete rows that don't have the max salary
    DELETE  FROM temp_fa
    where to_char(temp_fa.id)||to_char(temp_fa.val)||to_char(temp_fa.sal) in 
         (select to_char(id)||to_char(val)||to_char(sal) p_key
         from temp_fa
              MINUS
         (select to_char(x.id)||to_char(x.val)||to_char(x.sal) p_key
         from temp_fa x,
         (select val, id, max(sal) max_val from temp_fa
           group by  val, id ) y
           WHERE x.val = y.val and
            x.id  = y.id and
            x.sal =max_val
    HR: XE > select * from temp_fa order by id;
            ID        VAL        SAL
             1        100         20
             2        200         10
             3        300         30
             4        400         10
             5        500         20
    HR: XE > Regards,
    Ion
    Edited by: user111444777 on Sep 25, 2009 10:42 PM

  • I am trying to crop faces from old family group photos and paste them on to records in Family Tree Maker. When I do this, the pasted cropped image reverts to the original of the entire family. Is there a way of unlinking the original version from the crop

    I am trying to crop faces from old family group photos and paste them on to records in Family Tree Maker. When I do this, the pasted cropped image reverts to the original of the entire family. Is there a way of unlinking the original version from the cropped image?

    Are you copying the cropped images directly from Aperture's Browser window and then pasting into your family tree?
    It would be safer to export the cropped faces as new image files to a folder on your disk, and then drag them from there to the "Family Tree" window.
    To export select the cropped image versions in Aperture's browser and use the command "File > Export > Version". Select a suitable export preset from the pop-up menu, for example "Jpeg fit into ..." and select a folder to export to.
    Regards
    Léonie

  • I am already customer and want to upgrade and take the offer of $29.99/month for the complete CS for existing customers (which I qualify for) but when I try 'BUY' - it keeps sending me to this forum?? How do I get the $29.99/month deal?

    I am already customer and want to upgrade and take the offer of $29.99/month for the complete CS for existing customers (which I qualify for) but when I try 'BUY' - it keeps sending me to this forum?? How do I get the $29.99/month deal?

    Hi Bev,
    Thanks for the the email - I understand now.
    I would just like to ask another question with regards to my new order for complete Creative Cloud which you suggested. I have now pre-paid for a full year but I’m not
    sure when I can start downloading the other APPS as they don’t seem to be updating on my current Creative Cloud account app display. It still shows my old configuration
    of products (i.e. Photoshop etc) and my ‘activity stream’ relates back to 9 days ago.
    Please let me know how to get my new order activated.
    Thanks
    Kevin Bartley
    [personal information removed... Mod - https://forums.adobe.com/docs/DOC-3731]
    [This is an open forum, not Adobe support, please do not post personal information]
    [If you are posting using email, please turn your 'sig file' function OFF for posting]

  • I have a mid2009 MacBook Pro for which I have been using a USB WD HD for Time Machine.  I'd like to get a wireless HD  and start a new Time Machine backup for this Mac and retire the 5  year old WD drive.  Can I start over?

    I have a mid2009 MacBook Pro running Mavericks for which I have been using a USB WD HD for Time Machine.  I'd like to get a wireless HD  and start a new Time Machine backup for this Mac and retire the 5  year old WD drive.  Can I start over?

    no archive/ backup is perfect, HD clones can be set to make incremental additions, same as time machine however, though they are more time involved in doing so.
    See the + and - of all data backup/ archives below and "spread it around".... or the "dont put your eggs all in one basket" philosophy.
    Peace
    Data Storage Platforms; their Drawbacks & Advantages
    #1. Time Machine / Time Capsule
    Drawbacks:
    1. Time Machine is not bootable, if your internal drive fails, you cannot access files or boot from TM directly from the dead computer.
    2. Time machine is controlled by complex software, and while you can delve into the TM backup database for specific file(s) extraction, this is not ideal or desirable.
    3. Time machine can and does have the potential for many error codes in which data corruption can occur and your important backup files may not be saved correctly, at all, or even damaged. This extra link of failure in placing software between your data and its recovery is a point of risk and failure. A HD clone is not subject to these errors.
    4. Time machine mirrors your internal HD, in which cases of data corruption, this corruption can immediately spread to the backup as the two are linked. TM is perpetually connected (or often) to your computer, and corruption spread to corruption, without isolation, which TM lacks (usually), migrating errors or corruption is either automatic or extremely easy to unwittingly do.
    5. Time Machine does not keep endless copies of changed or deleted data, and you are often not notified when it deletes them; likewise you may accidently delete files off your computer and this accident is mirrored on TM.
    6. Restoring from TM is quite time intensive.
    7. TM is a backup and not a data archive, and therefore by definition a low-level security of vital/important data.
    8. TM working premise is a “black box” backup of OS, APPS, settings, and vital data that nearly 100% of users never verify until an emergency hits or their computers internal SSD or HD that is corrupt or dead and this is an extremely bad working premise on vital data.
    9. Given that data created and stored is growing exponentially, the fact that TM operates as a “store-it-all” backup nexus makes TM inherently incapable to easily backup massive amounts of data, nor is doing so a good idea.
    10. TM working premise is a backup of a users system and active working data, and NOT massive amounts of static data, yet most users never take this into consideration, making TM a high-risk locus of data “bloat”.
    11. In the case of Time Capsule, wifi data storage is a less than ideal premise given possible wireless data corruption.
    12. TM like all HD-based data is subject to ferromagnetic and mechanical failure.
    13. *Level-1 security of your vital data.
    Advantages:
    1. TM is very easy to use either in automatic mode or in 1-click backups.
    2. TM is a perfect novice level simplex backup single-layer security save against internal HD failure or corruption.
    3. TM can easily provide a seamless no-gap policy of active data that is often not easily capable in HD clones or HD archives (only if the user is lazy is making data saves).
    #2. HD archives
    Drawbacks:
    1. Like all HD-based data is subject to ferromagnetic and mechanical failure.
    2. Unless the user ritually copies working active data to HD external archives, then there is a time-gap of potential missing data; as such users must be proactive in archiving data that is being worked on or recently saved or created.
    Advantages:
    1. Fills the gap left in a week or 2-week-old HD clone, as an example.
    2. Simplex no-software data storage that is isolated and autonomous from the computer (in most cases).
    3. HD archives are the best idealized storage source for storing huge and multi-terabytes of data.
    4. Best-idealized 1st platform redundancy for data protection.
    5. *Perfect primary tier and level-2 security of your vital data.
    #3. HD clones (see below for full advantages / drawbacks)
    Drawbacks:
    1. HD clones can be incrementally updated to hourly or daily, however this is time consuming and HD clones are, often, a week or more old, in which case data between today and the most fresh HD clone can and would be lost (however this gap is filled by use of HD archives listed above or by a TM backup).
    2. Like all HD-based data is subject to ferromagnetic and mechanical failure.
    Advantages:
    1. HD clones are the best, quickest way to get back to 100% full operation in mere seconds.
    2. Once a HD clone is created, the creation software (Carbon Copy Cloner or SuperDuper) is no longer needed whatsoever, and unlike TM, which requires complex software for its operational transference of data, a HD clone is its own bootable entity.
    3. HD clones are unconnected and isolated from recent corruption.
    4. HD clones allow a “portable copy” of your computer that you can likewise connect to another same Mac and have all your APPS and data at hand, which is extremely useful.
    5. Rather than, as many users do, thinking of a HD clone as a “complimentary backup” to the use of TM, a HD clone is superior to TM both in ease of returning to 100% quickly, and its autonomous nature; while each has its place, TM can and does fill the gap in, say, a 2 week old clone. As an analogy, the HD clone itself is the brick wall of protection, whereas TM can be thought of as the mortar, which will fill any cracks in data on a week, 2-week, or 1-month old HD clone.
    6. Best-idealized 2nd platform redundancy for data protection, and 1st level for system restore of your computers internal HD. (Time machine being 2nd level for system restore of the computer’s internal HD).
    7. *Level-2 security of your vital data.
    HD cloning software options:
    1. SuperDuper HD cloning software APP (free)
    2. Carbon Copy Cloner APP (will copy the recovery partition as well)
    3. Disk utility HD bootable clone.
    #4. Online archives
    Drawbacks:
    1. Subject to server failure or due to non-payment of your hosting account, it can be suspended.
    2. Subject, due to lack of security on your part, to being attacked and hacked/erased.
    Advantages:
    1. In case of house fire, etc. your data is safe.
    2. In travels, and propagating files to friends and likewise, a mere link by email is all that is needed and no large media needs to be sent across the net.
    3. Online archives are the perfect and best-idealized 3rd platform redundancy for data protection.
    4. Supremely useful in data isolation from backups and local archives in being online and offsite for long-distance security in isolation.
    5. *Level-1.5 security of your vital data.
    #5. DVD professional archival media
    Drawbacks:
    1. DVD single-layer disks are limited to 4.7Gigabytes of data.
    2. DVD media are, given rough handling, prone to scratches and light-degradation if not stored correctly.
    Advantages:
    1. Archival DVD professional blank media is rated for in excess of 100+ years.
    2. DVD is not subject to mechanical breakdown.
    3. DVD archival media is not subject to ferromagnetic degradation.
    4. DVD archival media correctly sleeved and stored is currently a supreme storage method of archiving vital data.
    5. DVD media is once written and therefore free of data corruption if the write is correct.
    6. DVD media is the perfect ideal for “freezing” and isolating old copies of data for reference in case newer generations of data become corrupted and an older copy is needed to revert to.
    7. Best-idealized 4th platform redundancy for data protection.
    8. *Level-3 (highest) security of your vital data. 
    [*Level-4 data security under development as once-written metallic plates and synthetic sapphire and likewise ultra-long-term data storage]
    #6. Cloud based storage
    Drawbacks:
    1. Cloud storage can only be quasi-possessed.
    2. No genuine true security and privacy of data.
    3. Should never be considered for vital data storage or especially long-term.
    4. *Level-0 security of your vital data. 
    Advantages:
    1. Quick, easy and cheap storage location for simplex files for transfer to keep on hand and yet off the computer.
    2. Easy source for small-file data sharing.

  • Can I use my new 4gs on a line different then the one it was upgraded on. I have many phones on my account. I am not eligible for upgrade but I had to buy two new phones for others. Can I give one of them my old iPhone 4 and take the 4gs.?

    I have many phones on my account. I am not eligible for upgrade but I had to buy two new phones for others. Can I give one of them my old iPhone 4 and take the 4gs? Thinking maybe switch sim cards? Thanks in advance for any help

    Yes.
    Just call your provider and tell them what you want and they will help you get it done properly.

  • How to send a group email and have the recipients hidden?

    How do I send a group email and have the recipients hidden?

    I have a new OSX 27" iMac that is running Maverick. 
    RE: group emails, I am trying to omit individual recients and have tried the following options without success.
    1) Mail- Composing- checked "Automatically- Bcc"
    2) Mail- Composing- unchecked "when sending to a group, show all member addresses"
    The result is that all names continue to show up with email addresses for group emails.
    HELP!  HELP!  HELP!
    Lynn 

  • My Iphone 4s automatically synced when I started ITunes. When it did this it saved all of my pictures on my computer to my phone. How do I reverse this and take the pictures back off of my iPhone?

    My Iphone 4s automatically synced when I started ITunes. When it did this it saved all of my pictures on my computer to my phone. How do I reverse this and take the pictures back off of my iPhone?

    Yeah, my iPhone 4S sometimes manages to connect to wifi for about 10 minutes now. I think there is a problem related with the antenna because when the phone heats up, the WIFI stops working. I had a similar experience with my older iPhone 4S which I bought from the U.S.A. (unlocked version) but after a couple of days, WIFI icon grayed out and I wasn't able to switch it on and off. Now the phone I'm using was bought in Turkey from a local carrier, (it's not locked I suppose) I'm planning on upgrading to an iPhone 6 and I will try to get my 4S repaired. I hope it is something related with software rather than hardware. Because a friend of mine sent his phone to the local Apple store to be fixed, they sent the phone back claiming that they had repaired it. But in about 2 days, the phone shut itself down and never turned off back again lol. I don't want to experience the same thing. But anyway, thanks for your answer. At least now I know that I'm not the only one that has this problem .

  • I discovered a Lacuna in the system and I want to talk to Responsible to tell him and take the bonus

    I discovered a Lacuna in the system and I want to talk to Responsible to tell him and take the bonus

    What?
    The eagle flies at midnight?

  • If someone finds an iphone and its being tracked...then if such person restores it and takes the previous icloud account off, can the phone still be tracked?

    If someone finds an iphone and its being tracked...then if such person restores it and takes the previous icloud account off, can the phone still be tracked?

    In what regard? Restrictions would not impede in iCloud. All they do are allow certain changes (like age-appropriate content on App Store to be changed), and to prevent some apps from being shown on the device if they aren't going to be used, for example, I have restrictions active on my iPhone with the Youtube App turned off so it doesn't show on my home screen, and youtube links don't open into it (i find the application clunky and prefer the website).
    If the device is restored; Anything put in place by restrictions and the prior user are renderred null as the settings get completely erased.

  • How to count and display the number of records in a database table

    My webpage has a list of items and their details, every item has a button
    Read / Make comments that loads the item in its own page displaying
    a comments form and previous comments.
    This is all working fine.
    I would like to add to each item information stating how many comments have
    been made about that item.
    Allowing the user to see before hand if it is worth while clicking on the
    Read / Make comments button.
    Ideally each item will have a different number of comments.
    The problem I have is outputing the number of comments associated with each item.
    My comments table is called guest my items table is called titles.
    I'm sure mysql statement is correct -
    The table guest currently has 7 comments,
    Item 1 has 3 comments
    Item 2 has 2 comments
    Item 3 has 1 comment
    Item 4 has 1 comment
    When I test the query in dreamweaver
    $Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY guest.software_id";
    the outoput is a list showing 2, 3, 1, 1
    My problem is, getting the totals into my repeat region.
    I tried the following line
    <td align="left" valign="top" bgcolor="#e5f8cb">Current comments:<?php echo $row_Recordset1['COUNT']; ?></td>
    resulting in all comments so far displaying 0
    I have highlighted in bold the parts that I am having difficulty with.
    <?php
    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;
    $colname_rsTitles = "-1";
    if (isset($_GET['id'])) {
      $colname_rsTitles = $_GET['id'];
    mysql_select_db($database_abe, $abe);
    $query_rsTitles = sprintf("SELECT title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE id = %s ORDER BY id ASC", GetSQLValueString($colname_rsTitles, "int"));
    $rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
    $row_rsTitles = mysql_fetch_assoc($rsTitles);
    $totalRows_rsTitles = "-1";
    if (isset($_GET['id'])) {
      $totalRows_rsTitles = $_GET['id'];
    $colname_rsTitles = "-1";
    mysql_select_db($database_abe, $abe);
    $query_rsTitles = sprintf("SELECT title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE id = %s ORDER BY id ASC", GetSQLValueString($colname_rsTitles, "int"));
    $rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
    $row_rsTitles = mysql_fetch_assoc($rsTitles);
    $totalRows_rsTitles = mysql_num_rows($rsTitles);
    mysql_select_db($database_abe, $abe);
    $query_rs_comments = "SELECT * FROM guest";
    $rs_comments = mysql_query($query_rs_comments, $abe) or die(mysql_error());
    $row_rs_comments = mysql_fetch_assoc($rs_comments);
    $totalRows_rs_comments = mysql_num_rows($rs_comments);
    mysql_select_db($database_abe, $abe);
    $query_rs_users = "SELECT * FROM users";
    $rs_users = mysql_query($query_rs_users, $abe) or die(mysql_error());
    $row_rs_users = mysql_fetch_assoc($rs_users);
    $totalRows_rs_users = mysql_num_rows($rs_users);
    mysql_select_db($database_abe, $abe);
    $query_Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY guest.software_id";
    $Recordset1 = mysql_query($query_Recordset1, $abe) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    mysql_select_db($database_abe, $abe);
    if(!isset($_POST['softwareLevel'])){
    if (!isset($_GET['class_id'])) {
    //show all software titles
    $query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles ORDER BY id ASC";
    }else{
    //show software titles filtered by Literacy of Numeracy (using URL GET variable)
    $query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE titles.class_id = ". GetSQLValueString($_GET['class_id'], "int") ." ORDER BY id ASC";
    }else{
    //show software titles filtered by Level (using Form POST variable)
    $query_rsTitles = "SELECT id, title, company, `description`, resources, location, url, image, keyword, copies FROM titles WHERE titles.level_id = ". GetSQLValueString($_POST['softwareLevel'], "int") ." ORDER BY id ASC";
    $rsTitles = mysql_query($query_rsTitles, $abe) or die(mysql_error());
    $row_rsTitles = mysql_fetch_assoc($rsTitles);
    $totalRows_rsTitles = mysql_num_rows($rsTitles);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <?php $pagetitle="ABE Software Locator"?>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title><?php echo $pagetitle ?></title>
    <link rel="stylesheet" href="../../includes/styles.css" type="text/css" media="screen" />
    <style type="text/css">
    body {
    background-color: #FFF;
    </style>
    </head>
    <body>
    <?php include("../../includes/header.php"); ?>
        <div><table width="70%" border="0" align="center" cellpadding="3" cellspacing="0">
      <tr>
        <td width="29%" height="50" align="center"><a href="software_detail.php">Back to Locator</a></td>
        <td width="50%" align="center"><a href="../../index.php">Welcome Page</a></td>
        <td width="21%" align="center"><a href="../../logout.php">Log Out</a></td>
      </tr>
      <tr>
        <td colspan="3" align="center"><strong> There Are <span class="totalrecordsnumber"><?php echo $totalRows_rsTitles ?></span>  Software Titles Listed</strong></td>
      </tr>
      <tr>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
    </table>
        <?php do { ?>
          <table width="820" border="0" align="center" cellpadding="3" cellspacing="2">
            <tr>
              <td width="206" height="200" rowspan="3" align="center" bgcolor="#FFFFFF"><img src="images/<?php echo $row_rsTitles['image']; ?>" alt="<?php echo $row_rsTitles['title']; ?>" /></td>
              <td colspan="3" align="center" bgcolor="#086b50"><h2><?php echo $row_rsTitles['title']; ?></h2></td>
            </tr>
            <tr>
              <td colspan="3" align="center" bgcolor="#f6b824"><strong>Made by:</strong> <?php echo $row_rsTitles['company']; ?></td>
            </tr>
            <tr>
              <td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><p class="ptaglineheight"><strong>Description: </strong><?php echo $row_rsTitles['description']; ?></p></td>
            </tr>
            <tr>
              <td colspan="2" align="left" valign="top" bgcolor="#e5f8cb"><span class="tabletext"><strong>Keywords</strong></span><strong>: </strong><?php echo $row_rsTitles['keyword']; ?></td>
              <td colspan="2" align="left" valign="top" bgcolor="#e5f8cb"><strong>Resources:</strong> <?php echo $row_rsTitles['resources']; ?></td>
            </tr>
            <tr>
              <td colspan="4" align="left" valign="top" bgcolor="#e5f8cb"><strong>Web Address:</strong> <a href="<?php echo $row_rsTitles['url']; ?>" target="_blank"><?php echo $row_rsTitles['url']; ?></a></td>
            </tr>
            <tr>
              <td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><strong>Is installed on:</strong> <?php echo $row_rsTitles['location']; ?></td>
              <td width="195" align="left" valign="top" bgcolor="#e5f8cb"><strong>Copies available:</strong><?php echo $row_rsTitles['copies']; ?></td>
            </tr>
            <tr>
              <td colspan="3" align="left" valign="top" bgcolor="#e5f8cb"><a href="fulltitle.php?software_id=<?php echo $row_rsTitles['id']; ?>&amp;id=<?php echo $row_rsTitles['id']; ?>">Read / Make Comments About This Software</a></td>
              <td align="left" valign="top" bgcolor="#e5f8cb">Current comments:<?php echo $row_Recordset1['COUNT']; ?></td>
            </tr>
          </table> 
          <br />
          <?php } while ($row_rsTitles = mysql_fetch_assoc($rsTitles)); ?>
        </div>
        <?php include("../../includes/footer.php"); ?>
    </body>
    </html>
    <?php
    mysql_free_result($rsTitles);
    mysql_free_result($rs_comments);
    mysql_free_result($rs_users);
    mysql_free_result($Recordset1);

    I changed the mysql as you suggested GROUP BY titles.id
    and added a while loop to iterate over the data
    mysql_select_db($database_abe, $abe);
    $query_Recordset1 = "SELECT COUNT(guest.software_id) as COUNT, titles.id FROM titles LEFT JOIN guest ON titles.id = guest.software_id GROUP BY titles.id";
    $Recordset1 = mysql_query($query_Recordset1, $abe) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    $row_Recordset1 = mysql_query($query_Recordset1) or die(mysql_error());
    <td>Current comments:<?php
    if($row_Recordset1)
    while($row = mysql_fetch_array($row_Recordset1))
    echo $row['COUNT'];
    } ?></td>
    The first item now displays the following,
    comments:2311000000000000000000000000000
    all others
    comments:
    the number matched the database table exactly, 30 records 4 of which have 2, 3, 1, 1 comments.
    It looks as if the problem is trying to get the repeat region to pick up on it!

  • Query Designer in BI - How to cumulate value and get the Max and Min value.

    I want to create a report with  query designe of BI 7r. is it possible. the data from the cube will be
    Year ,           Exposed Quantity
    1999 ,             200
    2000 ,            100
    2001 ,            -100
    2002 ,             300
    2003 ,           - 200
    2004 ,             100
    2005 ,            -200
    Calculation should be - Refer the cumulative value field
    Year  ,          Exposure Quantity ,   Cumulative value
    1999  ,            200   ,                             200
    2000  ,            100  ,                              300
    2001  ,           -100 ,                               200
    2002  ,            300  ,                              500
    2003  ,          - 200  ,                              300
    2004  ,            100  ,                              400
    2005  ,           -200  ,                              -200
    An the out put of the report  should be Max value ie 500 and Min Value -200.
    My question is that is it possible to do in the front end ie in the Query Designer (BI 7) If so how.
    Edited by: Parakadavil Chacko Mathew on Oct 8, 2009 3:52 AM

    Hi there,
    Create 4 column,
    1st will show regular values for the key figure,
    2nd will show Cumulative value, in Query Designer, Just right click on the this 2nd key figure properties, calculation tab there you can check on Cumulated option, and define the calculation direction as Calculate along the Column.
    3rd will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as minimum.
    4th will show Minimum value , Just right click on the this 2nd key figure properties, calculation tab calculate single valuea as Maximum.
    Regards,
    Rajdeep Rane.

  • Query - Filter by a specific dynamic date - Return only the max date record

    Hello experts,
    I'm building a query. In this query I have a filter named validity date. I need to select a record where the max date is less than this filter.
    For example:
    Comp. Code | Plant | Mat. | Cost Type | Valid. Date | Value
    0000000001   00001  0001  xxxxxxxx    12.05.2008   2,00
    0000000001   00001  0001  xxxxxxxx    09.05.2008   1,00
    0000000001   00001  0001  xxxxxxxx    05.05.2008   0,50
    If the user set 13.05.2008 in the filter, the report should return:
    0000000001   00001  0001  xxxxxxxx    12.05.2008   2,00
    If the user set 11.05.2008 in the filter, the report should return:
    0000000001   00001  0001  xxxxxxxx    09.05.2008   1,00
    If the user set 08.05.2008 in the filter, the report should return:
    0000000001   00001  0001  xxxxxxxx    05.05.2008   0,50
    The problem is that the date will be dynamic and I'll need to return just one line for a combination of Company Code, Plant, Material and Cost Type. First of all I would like to know the best way to do it. Do I need to use virtual key figure? If so, anyone could tell me some steps to do it?
    Thanks in advance,
    Helder

    Not Virtual KeyFigure.
    You can achieve this with Restricted KeyFigure with the restriction with CalDay (Variable) which user input while Running the Query. Its more like a Bucket. SAP Delivered Buckets Query is in the below link. Check that query you will understand better about Bucket.
    http://help.sap.com/saphelp_nw04/helpdata/en/40/94af39a3488979e10000000a11402f/content.htm
    If not clear try to Install the BC Query and play with that you will know better.
    Thanks
    Sriram

  • Billing - iTunes doesn't try and take the money from my a/c. It takes me to the generic support home page instead.

    I had a problem with my bank account going overdrawn a few weeks ago (caused by a 3rd party taking money from my a/c and putting it overdrawn). An amount of $1.06 is showing as owed on my iTunes billing. There is money in my bank account now. When I try to download an update or a free app I get redirected to update my billing info. My debit card is the same number as before, the only difference is there is money in the acccout now. For some reason when I update my billing info using the same card number instead of Apple trying to take the $1.06 out of my account it directs me to the iTunes support home page which shows all the differnt countries flags.
    From what I can see there are no answers to my specific problem in the forums and as far as I know Apple doesn't offer a human being to talk with to get it sorted.
    Does anybody have any ideas how I could resolve this? I'm very frustrated with it that's for sure.

    If you mean that you are getting a message to contact iTunes Support then you can do so via this link and ask them for help : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then Purchases, Billing & Redemption
    But as far as I know debit cards are no longer accepted as a valid payment method - they are not listed on this page and there have been a number of posts recently about them being declined

Maybe you are looking for

  • How do i add an apple id for family sharing for my husband

    I am trying to set up family sharing and have added my daughters easily but when i try and invite my husband it says we cant as he email address is already associated with my apple id. How can i set him up to use family sharing?

  • Will the iPhone 5 also run on 3g or will it only be 4g LTE?

    i don't want to get it if it can't also run on 3g because where i live i can't really get 4G LTE

  • Bank details declined on iTunes/app store

    When I try to download a free app from App Store a notification pops up about billing when I go on there it's saying my bank details have been declined but all my details are still the same so how do I go about changeing but still wanting tissue the

  • Unknown Query Engine Error when doing a Verify Database

    Hi there, Using Crystal 10. Sybase Server. Have built a report that connects to a stored procedure. The stored procedure has since been updated, and new fields have been added. Usual process for me is to simply: 1. Go to Database > Verify Database 2.

  • Active new general  ledger accounting

    Dear all, We use SAP several years, after we upgrade to ECC5.0, I would like to active new general ledger accounting. In the SAP training material (AC210), it said that this action should be performed at new year, not mid-year. however, if I active i