Skip to content
Advertisement

Problem in getting this output using Join in SQL Server

I want to show a output like this,

Now here are my tables that will be used for join,

MockTestMaster (used column tot_marks)

MockTestDetails (segment_id, segment_name, tot_questions)

prd_template_question_type (used columns neg_marks)

prd_templatesection (I could use this table,but on my application user could add a section and which will not be inserted in this table because it will change the original template,so I inserted that section in MockTestDetails table)

Now problem of getting my output is the marks_if_wrong column of prd_template_question_type table.

Now here is the deal how to get neg_marks: if sectiontype_isMcq of prd_templatesection is true, then grab marks_if_wrong column of prd_template_question_type.

I tried this query:

Here is a fiddle of this problem

Advertisement

Answer

You can use the following code

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement