Riddhi Valecha

Riddhi Valecha

  • 443
  • 3.3k
  • 413.1k

SQL Server - Comparing records with current month and year

Apr 16 2021 10:29 AM
Hello Team,
 
I need help in making a SQL Query again.
 
I have two tables -
1. Asset Master 
 ID UserNameSerialNumberAssetTypeActive 
 1 Rohit S1224 CPU 1
 2 Janvi S45677    CPU 1
 3  Rohit S76544 Laptop 1
 4  Rohit S34567 iPAD 1
 5  Janvi S98778 Laptop 1
 6  Janvi S567890 Mobile 1
 
2. Table - Asset Certification -
 ID SerialNumber CertifiedBy CertifiedOn Active
 1 S1224 Rohit 2021-02-03 1
2 S34567 Rohit 2021-02-03 1
 3 S98778 Janvi 2021-04-16 1
 4 S76544 Rohit 2021-04-16 1
 5 S1224 Rohit2021-01-01  1
 6 S98778 Janvi 2021-01-01 1
 7 S76544 Rohit 2021-03-02 1
 8 S76544 Rohit 2021-03-01 1
 
Now, I need to load all the assets that are not certfied in the current month and year from table Asset Certication.
E.g. Current Month and YEar - April 2021.
So, I need all detail from Master table -  UserName, AssetType, SerialNumber and all records from Asset Certification table - where CertifiedOn is not - April 2021 (highlighted in yellow colour).
Please guide - How do I make the query ? 

Answers (5)