Tech Study

250+ SQL Programs for Practice | SQL Tutorial

SQL Tutorial

SQL Tutorial provides in-depth knowledge about the Database Management using MS SQL Server, MySQL Server. To understand more about SQL Server, MySQL Server or MongoDB, you must have basic understanding of SQL Programs for Practice.

What is SQL ?

  • SQL stands for Structured Query Language
  • SQL is used to store and fetch data in the database
  • SQL can be sub classified into DQL – Data Query Language, DML – Data Manipulation Language, DDL – Data Definition Language, TCL – Transaction Control Language, DCL – Data Control Language

What are the DQL(Data Query Language) ?

  • SELECT –  This allows to get data from the database based on certain conditions which can be provided in this query

What are the DDL(Data Definition Language) ?

  • CREATE – This creates a new table or database
  • ALTER  – This updates the structure of the table, adding/removing/updating a column etc
  • TRUNCATE – This deletes all the data in the table and resets the auto increment counter to 0
  • DROP – This removes the table from the group of tables in a database
  • COMMENT – This adds comments to a table column
  • RENAME – This renames the name of the existing table in the database

What are the DML(Data Manipulation Language) ?

  • INSERT –  This inserts the row in the table
  • UPDATE – This updates the data in the table, updating a column value of a row etc
  • DELETE – This deletes the data in the table, deleting one or more rows based on a condition
  • LOCK – This attains a lock on the table

What are the DML(Data Control Language) ?

  • GRANT –  This grants privileges to user on tables, views, procedures
  • REVOKE – This revokes privileges from user on tables, views, procedures

 

What are the TCL(Transaction Control Language) ?

  • BEGIN –  This starts a new transaction
  • COMMIT – This commits a transaction, so all the queries executed are saved
  • ROLLBACK – This rollbacks or undoes the set of queries executed the transaction till the provided savepoint.(It is more like a restoring of your system to a older version)
  • SAVEPOINT – This helps to create a version so that if required to undo, we can mention this version to be undone till
  • SET TRANSACTION – This specifies the type of transaction(SET TRANSACTION [ READ WRITE | READ ONLY ]);

List of SQL Programs for Practice

Below you will find the list of SQL programs, this will help to become a Database Developer or a DBA(Database Administrator)

Basic SQL programs for Practice | Database Practice with examples

  1. Write the query to get the branch and branch wise total(sum) admission fees, display it in ascending order according to admission fees
  2. Write the query to get no of students joined with respect to year and month from tblStudent table
  3. Write the query to get branch, no of students in a branch, total admission fees with respect to a branch from tblStudent table order by admission fees descending
  4. Write the query to get branch wise average admission fees from “tblStudent” table order by admission fees ascending order
  5. Write a SQL statement to display all students information
  6. Write a SQL query to get unique branch from tblstudent table
  7. Write a SQL query to Get the first name, last name, current date, admission date and difference between current date and admission date in days
  8. Write a SQL query to get student details from tblStudent table whose admission year is “2016”
  9. Write a SQL query to get student details from tblStudent table whose admission month is ‘June’
  10. Write a SQL query to get student details from tblStudent table whose admission date is before January 31st
  11. Write a SQL query to get student details from tblStudent table whose admission date is after January 31st 2018
  12. Write a SQL query to get position of ‘v’ in name ‘David’ from tblstudent
  13. Write a SQL query to get only year part of admission date from tblStudent
  14. Write a SQL query to get only month part of admission date from tblStudent
  15. Write a SQL query to get list of all students whose first name start with ‘Ma’ or ‘Da’
  16. Write a SQL query to get length of FirstName from tblstudent
  17. Write a SQL query to get FristName from tblStudent table after replacing ‘a’ with ‘$’
  18. Write a SQL query to get FirstName, Lastname, Scholarship amount from tblStudent and tblScholarship table for all students even if they didn’t get Scolarship
  19. Write a SQL query to get firstname from tblstudent with Hello prefix
  20. Write a SQL query to get FirstName from tblstudent after removing white spaces from right side
  21. Write a SQL query to get FirstName from tblstudent after removing white spaces from left side
  22. Write a SQL query to get first name from tblstudent in upper case
  23. Write a SQL query to get first name from tblstudent in lower case
  24. Write a SQL query to get details whose firstname starts with name “David”
  25. Write a SQL query to get database date
  26. Write a SQL query to get all students details from the tblStudent table order by LastName Ascending and Admission fees descending
  27. Write a SQL query to get all students details from the tblStudent table order by FirstName Descending
  28. Write a SQL query to get all students details from the tblStudent table order by FirstName Ascending
  29. Write a SQL query to get all student details from tblstudent whose “FirstName” start with letter ‘d’
  30. Write a SQL query to get all student details from tblstudent whose “FirstName” ends with ‘a’
  31. Write a SQL query to get all student details from tblstudent whose “FirstName” contains ‘a’
  32. Write a SQL query to get all student details from tblStudent table whose admission date between ‘2016-01-01’ and ‘2018-01-01’
  33. Write a SQL query to get admission date and time from tblStudent table
  34. Write a SQL query to display sum of two numbers 10 and 15
  35. Write a SQL query to display firstname and branch of student, who belongs to the branch ‘Computer Engineering’
  36. Write a SQL query to display a string “Hello World!”
  37. Write a SQL query to combine firstname and lastname and display it as “Full Name”
  38. Write a SQL query get fristname from tblstudent not start with any single character between a-l
  39. Write a Sql query get first name, admission year, admission month and admission date from tblStudent table
  40. Write a SQL query get all students details from tblStudent whose first name starts with ‘m’ and name contains 4 letters
  41. Write a SQL query get all students details from tblStudent whose first name ends with ‘a’ and name contains 4 letters
  42. Write a query to select TOP Nth (any number) admission fees from tblStudent table
  43. Write a query to select TOP 2 Admission fees from tblStudent table
  44. Write a query to select second highest admission fees from “tblStudent” table
  45. Write a query to select Minimum Admission fees from tblStudent table
  46. Write a query to select highest Admission fees from tblStudent table
  47. Write a query to select FirstName, LastName from tblStudent table in singal column
  48. Write a Query to get the first name, last name, current date, admission date and difference between current date and admission date in year
  49. Write a Query to get the first name, last name, current date, admission date and difference between current date and admission date in month
  50. Write a query to get students details from “tblStudent” whose admission fees is less than 1200
  51. Write a query to get students details from “tblStudent” whose admission fees is greater than 1200
  52. Write a query to get students details from “tblStudent” whose admission fees is between 900 and 1500
  53. Write a Query to get only time part of the “AdmissionDate” from tblStudent
  54. Write a query to get how many students exist in tblstudent
  55. Write a query to get 5 % of admission fees from Michael, 10% of admission fees from John and for other 15 % of admission fees as ‘Deducted_Admission_fee’ from tblStudent table
  56. Write a Query to get “AdmissionDate” in “yyyy/mm/dd” format, ex- “2019/05/06”
  57. Write a Query to get “AdmissionDate” in “dd mmm yyyy” format, ex- “06 May 2019”
  58. Write a query to display only firstname and branch from table student
  59. Top 100 SQL server queries Interview questions | SQL server interview questions
  60. SQL Server Advanced Questions – ‘Join’
  61. MS SQL Queries to retrieve data from tables
  62. List of SQL Query questions on Top, Union, admission fees and Group by questions
  63. List of SQL Query questions on Datetime
  64. How to find out Microsoft SQL Server Enterprise Edition Expiration Date
  65. How can I remove duplicate rows from large table

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more