Solved

Query multiple rows and display as a single row

Posted on 2008-06-20
4
1,345 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 50 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many‚Ķ
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

707 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