Solved

Query multiple rows and display as a single row

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Swadhin
From the Oracle SQL Reference (http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/queries006.htm) we are told that a join is a query that combines rows from two or more tables, views, or materialized views. This article provides a glimps…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

929 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now