Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1355
  • Last Modified:

Query multiple rows and display as a single row

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
raghx_2000
Asked:
raghx_2000
  • 2
  • 2
1 Solution
 
MilleniumaireCommented:
select file_num,
          name,
          date,
          sum(rec_cnt)
from mytable
group by file_num,
               name,
               date
0
 
MilleniumaireCommented:
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
 
raghx_2000Author Commented:
Not working. -:(
0
 
raghx_2000Author Commented:
select file_num,
          name,
          min(date),
          sum(rec_cnt)
from mytable
group by file_num,
               name
Thanks pal
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now