Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:23:46+00:00 2026-06-02T02:23:46+00:00

I am using SQL Server 2008 and I have 4 tables StudentAbsentees, Students, StudentSections

  • 0

I am using SQL Server 2008 and I have 4 tables StudentAbsentees, Students, StudentSections and Sections

In the StudentAbsentees table I am storing the studentId that are absent (absentees only) on a particular day like,

    StudentId     Time     Date        
   -----------   ------   ------
       1         10:00    2012-04-13

and in the StudentSections I am storing the studentId in a particular section like

 StudentId    SectionId
   ----------   ------------
      1              1
      2              1
      3              1

and in the Students table I am storing student details, likewise in Sections table I have section details like name and capacity of that section.

I need to join these tables and display whether the student is present/absent on a particular day… the result should be

StudentId    Status
---------    ------
    1         Absent
    2         Present
    3         Present

I can get the absentees list from these tables, I dunno how to display whether they are present/absent….can anyone help me here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:23:48+00:00Added an answer on June 2, 2026 at 2:23 am
    select * from (
       select s.id, 
              case 
                  when sa.date = '2012-01-01'
                  then 'absent'
                  else 'present' 
              end as status,
              ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY CASE WHEN sa.date = '2012-01-01' THEN 1 ELSE 2 END) AS RowNumber
       from students s
       left outer join studentabsentees sa on s.id = sa.studentid
    )
    as a where a.RowNumber = 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008 and I have a table that has a 'Status'
I'm using SQL Server 2008 and I have a table with three columns: Length
I am using T/SQL in SQL Server 2008 I have a table MyTable with
Using Microsoft SQL server 2008 I have a query that is in need of
I have a database that I have created using SQL Server Developer 2008. I
I'm using SQL Server 2008 and I have 3 tables, x , y and
I am using SQL Server 2008, and I have two tables Table1 contains 3.5
I'm using SQL Server 2008. I have a table Customers customer_number int field1 varchar
I am using SQL Server 2008. I have tables on which there are duplicate
I am using SQL Server 2008 R2. I have imported 2 tables from excel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.