In this lab 4 you will be working with some formating options. now that you know how to write queries and ask questions to the database and retrive any result that you want, we will now learn how to make your results look beautiful.

For a detailed discussion on most of the formatting commands available to you, just check out Formatting in SQL Plus.

To learn how to manipulate commands like storing commands, correcting commands etc, check out Manipulating Commands

Now that you have read that discussion, we will see how we can solve the questions in the lab manual.

1. Use the COLUMN columnname newname command to set the column names in the output. Then write the Select statement to retrieve the rows you want. Since we want them in reverse order, find out which command will give you in reverse order.

2. In this question there is a small mistake. remove the "like" in the accept command. accept is a command you use to get the values at runtime. For example, in the lab manual, you are accepting the grade name entered at runtime into the gname variable. The command does two things. First, it declares gname to be a variable and then when we run the command it will accept the user input and store it in gname.

To run this query open up the editor and name the file something. In that write all the commands one by one, in the order given. If you observe we have given you just the commands and not the values. For example, TTITLE is given, but the title itself is left to you. So now you have set different formatting options. Exit the editor and run it using the @ command and all the formatting options have been set. Now they will stay like that for the rest of the session.

3. With the above formatting options set, write a query to retrieve the result for the given query. This is a direct query as all the information you need is in the employee table, so you have to query only the employee table.

4. This needs, both the department and the employee table. Maybe you need to use nested queries for this. first select the different deprtments that come in employee table and then check to see which department does not figure in that list from the list of all the departments.

5. this involves a lot of date formatting, so refresh you memory about dates.