?
Solved

Query multiple rows and display as a single row

Posted on 2008-06-20
4
Medium Priority
?
1,347 Views
Last Modified: 2013-12-19
Hi There,
I have rows like the following
File_Num   Name    Date                               rec_cnt
1               MAXX   20/06/2008 3:30:32 PM  1
1               MAXX   20/06/2008 4:00:32 PM  2
1               MAXX   20/06/2008 4:30:32 PM  1
2               MAXX   21/06/2008 3:30:32 PM  1
2               MAXX   21/06/2008 4:00:32 PM  1
2               MAXX   21/06/2008 4:30:32 PM  1
Now i must display the above rows like the following
File_Num   Name    Date                               rec_cnt
1               MAXX   20/06/2008 3:30:32 PM  4
1               MAXX   21/06/2008 3:30:32 PM  3

Can you please help me with some query or view?
Thanks in advance
Regs
0
Comment
Question by:raghx_2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 16

Expert Comment

by:Milleniumaire
ID: 21830427
select file_num,
          name,
          date,
          sum(rec_cnt)
from mytable
group by file_num,
               name,
               date
0
 
LVL 16

Accepted Solution

by:
Milleniumaire earned 200 total points
ID: 21830457
Aaah, just noticed the times are different for each file num, so you will have to retrieve the min or maximum time depending on what you want to see:

select file_num,
          name,
          min(date),
          sum(rec_cnt)
from mytable
group by file_num,
               name

If you also need to group by date i.e. show a change of date (but not time) then try the following variation:

select file_num,
          name,
          min(date),
          sum(rec_cnt)
from mytable
group by file_num,
               name,
               trunc(date)
0
 
LVL 3

Author Comment

by:raghx_2000
ID: 21830477
Not working. -:(
0
 
LVL 3

Author Closing Comment

by:raghx_2000
ID: 31469117
select file_num,
          name,
          min(date),
          sum(rec_cnt)
from mytable
group by file_num,
               name
Thanks pal
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question