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 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 Group By In SQL
Group By is used to group the row having the same value like “Group by age of person” The GROUP BY statement is often used with aggregate functions. Mostly used aggregate function in group by is COUNT, MAX, MIN, SUM...
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...
Generate Unique Random Numbers In Sql With Stored Procedure
This procedure generates random unique numbers between two numbers. It gets 3 parameters. The first parameter is number you want to list, the second parameter is the start value and the last parameter is the end value. In this...