Solved

Cross tab query...

Posted on 2003-11-18
5
518 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

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

Suggested Solutions

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
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 recover a database from a user managed backup
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

867 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

15 Experts available now in Live!

Get 1:1 Help Now