Learn SQL Commands (Part-1)
T-SQL Commands for beginners
I will be using SQL Server Management Studio (SSMS)
Table Of Contents
- Create a Database
- Create a table
- Insert data into a table
- View data from the table
- View data by specific [Student Id]
- View data by specific [Student Name]
- View data by specific [Student Name] first character is ‘a’
- View data by specific [Student Name] the last character is ‘m’
- View Student in Descending order of [Student Id]
- Display the number of students in the table
- Display only [Student Name] from the table
- Insert data on a table with a Foreign key
- Display Name from the first table and subject, grades from the second table.
- Display the average grades of the student
- Display the average grades of the student in ascending order
- Display the average grades with different column names
- Display the Sum of the grades by Students
1. Create a database
It can be viewed in object explorer
2. Create a table
3. Insert data into the table
[Student Id] will be automatically added due to identity(1,1) means starting from 1 and increment by 1 -> (1,2,3,4……) and it will also be unique because it is a primary key.
4. View data from the table
5. View data by specific [Student Id]
6. View data by specific [Student Name]
7. View data by specific [Student Name] first character is ‘a’
8. View data by specific [Student Name] the last character is ‘m’
9. View Student in Descending order of [Student Id]
10. Display the number of students in the table
11. Display only [Student Name] from the table
I will be using another table for displaying more commands. The grading table contains students' grades in different subjects.
A foreign key is a key that has a primary key on another table, here it is [Student Id] from the Student table
And after inserting data I have the following data on the table
12. Insert data on a table with a Foreign key
13. Display Name from the first table and subject, grades from the second table
14. Display the average grades of the student
Note: Group by is required on using the Avg() function
15. Display the average grades of the student in ascending order
16. Display the average grades with different column names
17. Display the Sum of the grades by Students
Follow for more
Feel free to reach me or comment here