Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Cross tab query...

Posted on 2003-11-18
5
Medium Priority
?
524 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
[X]
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
  • 2
5 Comments
 
LVL 23

Accepted Solution

by:
seazodiac earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

715 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