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 6901569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:41:25+00:00 2026-05-27T07:41:25+00:00

I am developing a web application and now I need to make this application

  • 0

I am developing a web application and now I need to make this application able to generate some reports from its database. I have a huge database with a quite complicated structure. I came up with a large SQL Query and it was working fine with me until I changed a little bit the structure of the database. I modified it according to these changes but still it does not work. I tested it in the SQLServer Management Studio and I failed. Sometimes it tells me that the error is with syntax. Sometimes it tells me that the error with ”.

Simple structure of the database:

employee table: Name, Username, JobTitle, BadgeNo, EmpOrgType, DivisionID

Departments table: DepartmentCode, DepartmentName

courses table: CourseID, CourseName, GroupID

group table: GroupID, GroupName

employee_courses: employeeID, courseID

The first attribute in each table is the primary key of each table except for the last table, employee_courses table.

The query is:

select *
from
    (SELECT TOP (100) PERCENT 
            dbo.Divisions.DivisionName, 
            dbo.employee.EmpOrgType, 
            dbo.employee.Name, 
            T1.Username, 
            courses_2.CourseName, 
            CASE WHEN dbo.employee_courses.courseId IS NULL THEN '' '' 
                 ELSE ''Yes'' END AS CourseId
     FROM dbo.employee_courses 
     RIGHT OUTER JOIN dbo.courses AS courses_2 
     INNER JOIN (SELECT employee_1.Username, 
                        courses_1.CourseID
                 FROM dbo.employee AS employee_1 
                 CROSS JOIN dbo.courses AS courses_1) 
                                  AS T1 ON courses_2.CourseID = T1.CourseID 
     INNER JOIN dbo.employee ON T1.Username = dbo.employee.Username 
                             ON dbo.employee_courses.employeeId = T1.Username AND
                                dbo.employee_courses.courseId = T1.CourseID
     ORDER BY T1.Username
    ) DataTable

This query should retrieve the information of the employee: Name, Username, JobTitle, BadgeNo, EmpOrgType and DivisionName. Then, it should display the courses that he took them from the courses table with mentioning the GroupName of those taken courses.

  • 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-05-27T07:41:25+00:00Added an answer on May 27, 2026 at 7:41 am

    Do you actually want to see the single quotes in your result string? If yes, try:

    SELECT *
    FROM   (SELECT TOP (100) PERCENT dbo.divisions.divisionname,
                                 dbo.employee.emporgtype,
                                 dbo.employee.name,
                                 t1.username,
                                 courses_2.coursename,
                                 CASE
                                   WHEN dbo.employee_courses.courseid IS NULL
                                 THEN ''' '''
                                   ELSE '''Yes'''
                                 END AS courseid
        FROM   dbo.employee_courses
               RIGHT OUTER JOIN dbo.courses AS courses_2
                                INNER JOIN (SELECT employee_1.username,
                                                   courses_1.courseid
                                            FROM   dbo.employee AS employee_1
                                                   CROSS JOIN dbo.courses AS
                                                              courses_1)
                                           AS t1
                                  ON courses_2.courseid = t1.courseid
                                INNER JOIN dbo.employee
                                  ON t1.username = dbo.employee.username
                 ON dbo.employee_courses.employeeid = t1.username
                    AND dbo.employee_courses.courseid = t1.courseid
        ORDER  BY t1.username) datatable  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing web application where users have collection of tags. I need to
I am developing a web application and i am integrating jquery in it... Now
I've been developing Web applications for a while now and have dipped my toe
I've been developing web applications for 2 years now, and have been into simpler
I am developing a web application which has Chart Controls. I have developed a
I am developing a web application using Struts 2.1.2 and Hibernate 3.2.6.GA. I have
I'm developing a web application and I need to mix Forms & Windows authentication
I'm developing a web application for mobile browsers. Right now most of development is
I am developing a web application for a comapny. This application provides the users
I'm developing an Asp.Net 3.5 application and I need to print some application generated

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.