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.
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:
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:
0 comments:
Post a Comment