In this tutorial, i’ll show you How toorder by 2 columns in Sql. You need to display records from a given table sorted by two columns. Example: List all products sorted by Category ID (descending), then by UnitPrice:...
Tag - SQL Queries and Answers
How to Use SQL ‘Order By’ Clause
In this tutorial, we’ll learn How to use order by clause in SQL. Order by clause is used to sort the fetched data either in ascending or descending order. When we execute our select statement we get unsorted results as our...
SQL Queries Examples With Answers
This article will cover all Microsoft SQL server interview questions from basic to advanced level. Before starting let’s create and populate tblstudent and tblScholarship table using following...
Add Multiple Records To A Table With One Query In Sql
In this post we will learn how to add multiple rows to a table with one query. Example 1: Add the authors table the authors whose names are Arthur Machen and Jack London in one query. Insert into authors (name,surname)...
Create A Stored Procedure Calculate Power Of A Number In Sql
In this example we will create a procedure that calculates power of given number. Transact-SQL Create Procedure myPower(@num int,@pow int, @result int output) As Begin Declare @i int = 0; Set @result = 1 while(@i<@pow) Begin...
Calculating Factorial of Given Number in SQL with Stored Procedure
In this tutorial we will write “Stored Procedure” calculates the factorial of a number. That is specified at below. Transact-SQL Create procedure factor(@number int) as begin Declare @i int = 1,@result int=1 while...
SQL Query to Select Records From a Table if the Birthdate is Next Week
In this post,I’ll show yo How to List students whose birth date is in next week. SQL Query: Transact-SQL Select * from students where datepart(dy,birthdate) between datepart(dy,dateadd(dd,1,getdate())) and...
SQL Query to Select Records From a Table if the Birthdate is Tomorrow
In this post, I’ll show yo How to List students whose birth date is tomorrow in SQL table. C# Select * from students where MONTH(birthdate) = MONTH(dateadd(dd,1,getdate())) and Day(birthdate) = Day(dateadd(dd,1,getdate()))...
SQL Query to Select Records From a Table if the Birthdate is Today
In this example, I’ll show you How to List students whose birth date is today. C# Select * from students where MONTH(birthdate) = MONTH(getdate()) and Day(birthdate) = Day(getdate()) 12345 Select * from students where...
Sql Query Examples With Answers (40+ Examples)
There are move over 40 SQL queries and answers in this article. Queries are working on the following database. SQL SELECT Queries Examples Example 1: List all the records in the student chart Transact-SQL select * from...