Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 4729

How to get rows which are not in another table using subquery?

$
0
0

Hi all,

        i have two tables Student  and Daily Attendance  with following structure ,as i want to extract students   of a class order by roll number which are not in Daily Attendance table , i know it will be solved by subquery but I don't know how to solve it,Please help me to sort this problem.I am stuck.

Student:-

CREATE TABLE [dbo].[Student](
[Student_Id] [bigint] IDENTITY(1,1) NOT NULL,
[Course_Id] [smallint] NULL,  //Foreign key
[Class_Id] [int] NULL,  //Foreign key
[Batch_Year] [varchar](20) NULL,
[Student_Initials] [varchar](20) NULL,
[Student_firstname] [varchar](20) NULL,
[Student_middlename] [varchar](20) NULL,
[Student_lastname] [varchar](20) NULL,
[Gender] [varchar](20) NULL,
[Roll_number] [varchar](30) NULL,)

Daily Attendance table:-

CREATE TABLE [dbo].[Daily_Attendance](
[Daily_Attendance_Id] [bigint] NOT NULL,
[Class_Id] [int] NULL,
[Date_Of_Attendance] [datetime] NULL,
[Week_Day_Id] [smallint] NULL,
[Period_No] [smallint] NULL,
[Subject_Id] [int] NULL,
[Faculty_Id] [bigint] NULL,
[Student_Id] [bigint] NULL,
[Attendance] [nchar](10) NULL,
 CONSTRAINT [PK_Daily_Attendance] PRIMARY KEY CLUSTERED 
(
[Daily_Attendance_Id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO



Viewing all articles
Browse latest Browse all 4729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>