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 Query Examples
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...
How to Use SQL SELECT Statement
SQL Code: Transact-SQL SELECT column1, column2, ... FROM table_name; SELECT * FROM Table_Name /* Select all columns from Table */ SELECT TOP 10 FROM Table_Name /* Select top 10 Result */ 12345678 SELECT column1, column2, ...
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...
Trigger Examples in SQL
In this tutorial i’ll create SQL trigger examples. This examples will help you to learn how to write triggers. If you didn’t download the database you can download from here. Examples Example 1: Trigger prevents the...
SQL Query to List only the Count of Female Students in Each Class
In this SQL Query Example, We’ll learn How to List only the Count of Female Students in Each Class. SQL Query: C# Select class,gender,count(*) as StudentCount from students where gender = 'F' group by gender,class 123456...
SQL Query to List only the Count of Male Students in Each Class
In this SQL Query Example, We’ll learn How to List only the Count of Female Students in Each Class. SQL Query: C# Select class,gender,count(*) as StudentCount from students where gender = 'F' group by gender,class 123456...