Solved

Cross tab query...

Posted on 2003-11-18
5
517 Views
Last Modified: 2012-05-04
Hello,

Can anyone help in writing cross tab query in oracle 8i?

Here is the Scenario:

We have two columns timesheet_date, timesheet_hrs.

If the timesheet date is 'Sunday' the value should be shown under the column 'Sunday", if 'Monday' the value should be shown underthe column 'Monday' and so on...

The output will be:

Sunday  Monday  Tuesday  Wednesday  Thursday  Friday  Saturday
8
               8
                              8
                                                8
                                       
Any help is appreciated!

Regards
-Venkitta
0
Comment
Question by:venkitta
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 50 total points
ID: 9774022
try:

select decode(timesheet_date, 'Sunday', timesheet_hrs) "Sunday",
          decode(timesheet_date, 'Monday', timesheet_hrs) "Monday",
          decode(timesheet_date, 'Tuesday', timesheet_hrs) "Tuesday",
          decode(timesheet_date, 'Wednesday', timesheet_hrs) "Wednesday",
          decode(timesheet_date, 'Thursday', timesheet_hrs) "Thursday",
          decode(timesheet_date, 'Friday', timesheet_hrs) "Friday",
          decode(timesheet_date, 'Saturday', timesheet_hrs) "Saturday"
From <your_table>;
0
 

Author Comment

by:venkitta
ID: 9774055
Thanks a lot. It works.  Appreciate all your help
0
 
LVL 23

Expert Comment

by:seazodiac
ID: 9774073
you are very welcome, enjoy being here with you all
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

747 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