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
Solved

Query multiple rows and display as a single row

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Bash Script to Analyze Oracle Schemas 11 117
Create Index on a Materialized View 5 32
Database Design Dilemma 6 58
How to create an alias for a column name in ORACLE sql ? 2 25
Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
Via a live example, show how to take different types of Oracle backups using RMAN.

809 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