Learn SQL Commands (Part-1)

T-SQL Commands for beginners

I will be using SQL Server Management Studio (SSMS)

Table Of Contents

  1. Create a Database
  2. Create a table
  3. Insert data into a table
  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
  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
  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

It can be viewed in object explorer

[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.

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

Note: Group by is required on using the Avg() function

Feel free to reach me or comment here

www.linkedin.com/in/mwaseemaw

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store