Solved

Cross tab query...

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Have you ever had to make fundamental changes to a table in Oracle, but haven't been able to get any downtime?  I'm talking things like: * Dropping columns * Shrinking allocated space * Removing chained blocks and restoring the PCTFREE * Re-or…
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.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

830 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