Most Frequently asked SQL Queries in Interview -Programmer's Mind


Friends Here are some Most Frequently asked SQL Queries for Beginners along with output.

Table:

Let us consider a table BOOK which contains FOUR columns as BID, BNAME, AUTHOR and RDATE. Here BID is Book ID, BNAME is name of the book, AUTHOR is the name of the author for that book and RDATE is the date on which that book was released.
SQL-Queries-In-interview


















Now let us try to write some interesting queries for above table.

Question 1: 

Write a query to retrieve all the books whose names are starts with a vowel (a,e,i,o,u)

Query :

  select bname from book where substr(bname,1,1) in ('a','e','i','o','u');

Output: 







Question 2:

Write a query to retrieve all the book which are released in the month of october.

Query: 

select bname from book where MONTH(rdate)=10;

Output:


SQL-Queries-In-interview









Most Optimized Program for Prime Number - Programmer's Mind

Question 3: 

Write a query to retrieve all the authors whose names are palindromes 

Query: 

select author from book where author=REVERSE(author);

Output:

Question 4: 

Write a query to retrieve all the books for which author name ends with vowel

Query: 

select bname from book where RIGHT(author,1) in ('a','e','i','o','u');

Output: 

SQL-Queries-In-interview


Share on Google Plus
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment