Skip to content

Tag: sql-server

How to properly perform a SELECT query [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 12 months ago. Improve this question I h…

How to add pagination to this dynamic sql

I have the following table with its respective data I wanted to be able to sort the dynamic column example sort by ‘StudentName’ ASC it would sort data using column returning When sorting by StudentName: When sorting by Grade ASC: When sorting by TeacherName ASC (different table) I have manage to …

Check value if exist in another table within Select Query

I have three tables first table stores user basic Info, the second table stores that user who exist in LDAP directory and third table store common information of both tables. below is the table structure I want name from a table if the value is not matched then check to another table. the desired output looks…

SQL Query to determine number of tables

I have this table and I’m trying to determine how many Tables (in a restaurant) are awaiting food. The table( in the database) has the following columns: TableNumber, ObjectType, ObjectDescription and Quantity (amongst others). I made this query to see what is ordered, but would like to know how many un…

Filter on Rows that are Within a Certain Timeframe

I have a table of patients that were admitted and discharged from the hospital. I am trying to find any patients that have an admission within 30 days of their previous discharge date. So for example, I have the table: Name Admission Date Discharge Date Patient A 1/1/2021 1/5/2021 Patient A 1/7/2021 1/10/2021…

Getting null data for left join on same table twice

I have some tables like this: Employee: Teams: TeamMember: I am trying to get list of employees with info regarding who they are : Team Member or Team Leader or Individual. Current output: Expected output: Query: Only issue here is that I am getting TeamId and TeamName as blank for “Team Leader” d…