Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 duplicate records show while it actually...

Author  Topic 

asifbhura
Posting Yak Master

165 Posts

Posted - 2013-09-06 : 08:11:11
Hello

my query is


SELECT TOP 100 PERCENT 0 AS FeeCollectionDetail_Id, 0 AS FeeCollection_Id,mst.Admission_Id AS Student_Id, mst.Student_RegNo, mst.Student_Name,
'' AS FromMonth_Date, '' AS ToMonth_Date, 0 AS Fee_Amount, 0 AS Fee_Library, 0 AS Fee_Computer, 0 AS Fee_Transportation, 0 AS Fee_Sports,
0 AS Fee_Art, 0 AS Fee_Admission, 0 AS Fee_Insurance, 0 AS Fee_Discount, 0 AS Fee_Other, mst.Family_Id, ISNULL(dbo.vw_Section.Grade_Section,
N'') AS Grade_Section
FROM dbo.tbl_Admission mst INNER JOIN
dbo.tbl_Family dtl ON mst.Family_Id = dtl.Family_Id INNER JOIN
dbo.tbl_Enrollment ON mst.Admission_Id = dbo.tbl_Enrollment.Student_Id INNER JOIN
dbo.vw_Section ON dbo.tbl_Enrollment.Section_Id = dbo.vw_Section.Section_Id
WHERE (mst.Is_Active = 1) AND (dbo.tbl_Enrollment.Year_Id >= '8')
ORDER BY mst.Family_Id


normally it works fine

but when we promote student to next class it shows bothe records,
with current grade and the new grade which we promote student to next grade..

I want to display with the latest grade which means where we promoted him,

please help me out

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-09-06 : 08:21:45
While joining dbo.vw_Section view in the JOIN take only Latest Sections of each student and then join...
If you doesn't get my point post us back with dbo.vw_Section column names...

--
Chandu
Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2013-09-06 : 08:32:45
SELECT dbo.tbl_Grade.Grade_Id, dbo.tbl_Grade.Grade_Name, dbo.tbl_Section.Section_Id, dbo.tbl_Section.Section_Name,
dbo.tbl_Grade.Grade_Name + ' - ' + dbo.tbl_Section.Section_Name AS Grade_Section, dbo.tbl_Section.Employee_Id
FROM dbo.tbl_Section INNER JOIN
dbo.tbl_Grade ON dbo.tbl_Section.Grade_Id = dbo.tbl_Grade.Grade_Id

here is the code for vw.section
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-09-06 : 09:18:57
which table gets data if student get promoted to next grade ?


--
Chandu
Go to Top of Page

asifbhura
Posting Yak Master

165 Posts

Posted - 2013-09-06 : 17:27:25
the table is tbl_Enrolment where students get promoted and structure is

enrolment_id, year_id,student_id, section_id

and tbl_grade structure is grade_id, grade_name

and tbl_Section structure is section_id, grade_id, section_name
Go to Top of Page
   

- Advertisement -