SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 duplicate records show while it actually...
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

asifbhura
Posting Yak Master

India
164 Posts

Posted - 09/06/2013 :  08:11:11  Show Profile  Reply with Quote
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

Edited by - asifbhura on 09/06/2013 08:13:51

bandi
Flowing Fount of Yak Knowledge

India
2168 Posts

Posted - 09/06/2013 :  08:21:45  Show Profile  Reply with Quote
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

India
164 Posts

Posted - 09/06/2013 :  08:32:45  Show Profile  Reply with Quote
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

Edited by - asifbhura on 09/06/2013 08:33:28
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2168 Posts

Posted - 09/06/2013 :  09:18:57  Show Profile  Reply with Quote
which table gets data if student get promoted to next grade ?


--
Chandu
Go to Top of Page

asifbhura
Posting Yak Master

India
164 Posts

Posted - 09/06/2013 :  17:27:25  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000