如题。
使用distinct后数据是1条,如果不使用则出现6条,拜膜高手...

解决方案 »

  1.   

    什么意思呀,不明白.
    你加上distinct不就得了吗
      

  2.   

    我使用的asp.net2.0分页控件,如果使用了distinct数据显示在gv中是1条,但是地下的总记录数显示是6,
    而且还有一个问题。如下:select  distinct Count(pj.ProjectID) from OLTR_ExamTestPaper as etp 
    inner join OLTR_StudyStudentRCourse as rc on etp.CourseID=rc.CourseID 
    inner join OLTR_StudySubjectRCourse as src on etp.CourseID=src.CourseID 
    inner join OLTR_StudyProjectRSubject as rs on src.SubjectID=rs.SubjectID 
    inner join OLTR_StudyProject as pj on rs.ProjectID=pj.ProjectID and etp.PaperAgain=1 
    and (StartTime <= getdate() and getdate() <= Endtime )
    where rc.tag<>1 and rc.CourseID not in(select distinct pr.CourseID 
    from OLTR_ExamPaperRecard as pr) and rc.StudentID='S08030012' and rs.ProjectID='P08120001'我想要得到count()的值.我想得到1 ,却出来6 ,如何是好a 加distinct也不行!!!!????????
      

  3.   

    distinct不会影响count.你不用COUNT不行吗.用DATATABLE.ROWS.COUNT来显示记录的条数.
      

  4.   

    在使用join時候的注意點:
    如果只要使用join的表中某個或幾個字段,就不要join整個表!!!!
    select  distinct Count(pj.ProjectID) from OLTR_ExamTestPaper as etp 
    inner join (select distinct CourseID from OLTR_StudyStudentRCourse) as rc on etp.CourseID=rc.CourseID 
    inner join (select distinct CourseID from OLTR_StudySubjectRCourse) as src on etp.CourseID=src.CourseID 
    inner join (select distinct subjectid from OLTR_StudyProjectRSubject) as rs on src.SubjectID=rs.SubjectID 
    inner join (select distinct ProjectID from OLTR_StudyProject as pj on rs.ProjectID=pj.ProjectID and etp.PaperAgain=1 
    and (StartTime <= getdate() and getdate() <= Endtime )
    where rc.tag<>1 and rc.CourseID not in(select distinct pr.CourseID 
    from OLTR_ExamPaperRecard as pr) and rc.StudentID='S08030012' and rs.ProjectID='P08120001'
      

  5.   

    那你使用distinct不就行了?重复是来自一个表还是多个表?left join?
      

  6.   

    sql 里用count读数
    C# 里用tables[i].rows.count