In this article, you will find basic to most puzzled Microsoft SQL Server queries to retrieve data from tables with an example.
So, before starting let’s create and populate tblstudent table using following script.
250+ SQL Programs for Practice | SQL Tutorial
Top 100 SQL Queries Interview Questions
How to find out Microsoft SQL Server Enterprise Edition Expiration Date
How can I remove duplicate rows from large table
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
SQL Server Advanced Questions – ‘Join’
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
Write the query to get no of students joined with respect to year and month from tblStudent table
Write the query to get branch wise average admission fees from “tblStudent” table order by admission fees ascending order
Write the query to get the branch and branch wise total(sum) admission fees, display it in ascending order according to admission fees
Write a query to get how many students exist in tblstudent
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
Write a query to get students details from “tblStudent” whose admission fees is between 900 and 1500
Write a query to get students details from “tblStudent” whose admission fees is greater than 1200
Write a query to get students details from “tblStudent” whose admission fees is less than 1200
Write a query to select FirstName, LastName from tblStudent table in singal column
Write a query to select Minimum Admission fees from tblStudent table
Write a query to select highest Admission fees from tblStudent table
Write a query to select TOP 2 Admission fees from tblStudent table
Write a query to select second highest admission fees from “tblStudent” table
Write a query to select TOP Nth (any number) admission fees from tblStudent table
List of SQL Query questions on Top, Union, admission fees and Group by questions
Write a Query to get only time part of the “AdmissionDate” from tblStudent
Write a Query to get “AdmissionDate” in “yyyy/mm/dd” format, ex- “2019/05/06”
Write a Query to get “AdmissionDate” in “dd mmm yyyy” format, ex- “06 May 2019”
Write a Query to get the first name, last name, current date, admission date and difference between current date and admission date in year
Write a Query to get the first name, last name, current date, admission date and difference between current date and admission date in month
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
Write a SQL query to get all student details from tblStudent table whose admission date between ‘2016-01-01’ and ‘2018-01-01’
Write a SQL query to get only year part of admission date from tblStudent
Write a SQL query to get only month part of admission date from tblStudent
Write a SQL query to get database date
Write a SQL query to get admission date and time from tblStudent table
Write a SQL query to get student details from tblStudent table whose admission month is ‘June’
Write a SQL query to get student details from tblStudent table whose admission date is before January 31st
Write a SQL query to get student details from tblStudent table whose admission date is after January 31st 2018
Write a SQL query to get student details from tblStudent table whose admission year is “2016”
Write a Sql query get first name, admission year, admission month and admission date from tblStudent table
List of SQL Query questions on Datetime
Write a SQL query get fristname from tblstudent not start with any single character between a-l
Write a SQL query get all students details from tblStudent whose first name ends with ‘a’ and name contains 4 letters
Write a SQL query get all students details from tblStudent whose first name starts with ‘m’ and name contains 4 letters
Write a SQL query to get FristName from tblStudent table after replacing ‘a’ with ‘$’
Write a SQL query to get length of FirstName from tblstudent
Write a SQL query to get FirstName from tblstudent after removing white spaces from left side
Write a SQL query to get FirstName from tblstudent after removing white spaces from right side
Write a SQL query to get firstname from tblstudent with Hello prefix
Write a SQL query to get position of ‘v’ in name ‘David’ from tblstudent
Write a SQL query to get all students details from the tblStudent table order by LastName Ascending and Admission fees descending
Write a SQL query to get all students details from the tblStudent table order by FirstName Descending
Write a SQL query to get all students details from the tblStudent table order by FirstName Ascending
Write a SQL query to get list of all students whose first name start with ‘Ma’ or ‘Da’
Write a SQL query to get all student details from tblstudent whose “FirstName” ends with ‘a’
Write a SQL query to get all student details from tblstudent whose “FirstName” start with letter ‘d’
Write a SQL query to get all student details from tblstudent whose “FirstName” contains ‘a’
Write a SQL query to combine firstname and lastname and display it as “Full Name”
Write a SQL query to get unique branch from tblstudent table
Write a SQL query to get first name from tblstudent in lower case
Write a SQL query to get first name from tblstudent in upper case
Write a SQL query to get details whose firstname starts with name “David”
Write a SQL query to display firstname and branch of student, who belongs to the branch ‘Computer Engineering’
Write a query to display only firstname and branch from table student
Write a SQL query to display sum of two numbers 10 and 15
Write a SQL query to display a string “Hello World!”
Write a SQL statement to display all students information
In this article, you will find basic to most puzzled Microsoft SQL Server queries to retrieve data from tables with an example.
So, before starting let’s create and populate tblstudent table using following script.
Create table tblStudent
(
StudentId int,
FirstName varchar(50),
LastName varchar(50),
Admission_fee int,
Admission_date datetime,
Branch varchar(50),
)
StudentId | FirstName | LastName | Admission_fee | Admission_date | Branch |
---|---|---|---|---|---|
1 | John | Smith | 1000 | 2018-06-10 | Computer Engineering |
2 | David | Jones | 1200 | 2018-06-20 | Civil Engineering |
3 | Michael | Johnson | 900 | 2018-08-15 | Chemical Engineering |
4 | Chris | Lee | 1500 | 2018-07-10 | Electrical Engineering |
5 | Mike | Brown | 1600 | 2018-09-10 | Mechanical Engineering |
6 | Lisa | Smith | 1800 | 2018-07-10 | Computer Engineering |
7 | Mary | Smith | 1600 | 2018-06-11 | Computer Engineering |
Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …
C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …