17 Mar Jenny Ashley Meera Jane
Query 1
John is a chef in a restaurant and has recently bought a new cookbook . The cookbook has so many recipes that John has to store information about them in a database.
Each recipe is described on exactly one page. No two recipes share the same page. Some pages have no recipe and are empty.
You are given a non-empty table recipes with following structure.
Create table recipes(page_no integer not null, title varchar(30) not null, unique(page_no));
Each record in the table recipes represents a single recipe from the cookbook . The column page_no contains the number of the page which the recipe appears on. The column title contains the title of the recipe
We would like to see a representation of the cookbook. More precisely , we would like to know what is printed on consecutive pages of the book.
There are 2*N-1 pages . After the last non-empty page there is at most one empty page. Your representation should describe all pages from number 0 to 2*N-1
Page 0(the internal side of the front cover) is guaranteed to be empty. Page 2*n-1 (the internal side of the back cover) can be non-empty. The cookbook contains at least one recipe.
Write an SQL query that runs a tale consisting of two colums left_title,right_title . The K-th row (counting from 0) should contain the title of the page with number 2*K in the first column and the title of the page with number 2*k+1 in the second column. If the page does not contain recipe , there should be NULL in the appropriate cell. Each page should appear in the table.
For E.g given following data:
page_no | title
——————–
1 | Scrambled eggs
2 | Fondue
3 | Sandwitch
4 | Tomato soup
6 | Liver
your query should return the following row set
left_title | right_title
—————————–
NULL | Scrambled eggs
Fondue | Sandwitch
Tomato Soup | NULL
Liver | NULL
Query 2
Pivot the Occupation column in OCCUPATIONS so that each Name is sorted alphabetically and displayed underneath its corresponding Occupation. The output column headers should be Doctor, Professor, Singer, and Actor, respectively.
Note: Print NULL when there are no more names corresponding to an occupation.
Input Format
The OCCUPATIONS table is described as follows:
Occupation will only contain one of the following values: Doctor, Professor, Singer or Actor.
Sample Input
Sample Output
Jenny Ashley Meera Jane
Samantha Christeen Priya Julia
NULL Ketty NULL Maria
Explanation
The first column is an alphabetically ordered list of Doctor names.
The second column is an alphabetically ordered list of Professor names.
The third column is an alphabetically ordered list of Singer names.
The fourth column is an alphabetically ordered list of Actor names.
The empty cell data for columns with less than the maximum number of names per occupation (in this case, the Professor and Actor columns) are filled with NULL va
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.