select pass fail, PASS/(PASS+FAIL) as result from wip;
试试.

解决方案 »

  1.   

    select pass, fail, pass/(pass+fail) as result from wip
    用此语句来生成数据集,
    DataGrid1.DataBind();
    在DataGrid1的生成属性中把result的格式设定为{o:p}即可显示为只取小数点后2位数的百分比
      

  2.   

    PASS/(PASS+FAIL)所在的BOUNDCOLUMN调用这个函数,可是这个,我也只是会想,不会实践.
    用datatable实现
      

  3.   

    '设置主题列如果太长用 "…"显示 ,将发布日期设置成组合列
            Dim table As DataTable = ds.Tables("gz")
            table.Columns.Add(New DataColumn("日期", GetType(String)))
            table.Columns.Add(New DataColumn("主题", GetType(String)))        Dim i As Integer
            Dim zt As String
            Dim d1 As Date
            Dim d2 As Date        For i = 0 To table.Rows.Count - 1
                zt = Trim(table.Rows(i).Item("subject"))
                If ch(zt) > 20 Then
                    table.Rows(i).Item("主题") = Left(zt, 18) & "…"
                Else
                    table.Rows(i).Item("主题") = zt
                End If
                d1 = table.Rows(i).Item("createdate")
                d2 = table.Rows(i).Item("lastdate")
                table.Rows(i).Item("日期") = Format(d1, "MM/dd") & "-" & Format(d2, "MM/dd")
            Next        DataGrid1.DataSource = table.DefaultView
    不知道你是不是这个意思
      

  4.   

    在BOUNDCOLUMN里面如何处理得到是带两位小数的百分数你要是只想得到带两位小数的百分数,只需要在datagrid属性生成器中设置一下就行了在PASS/(PASS+FAIL)这一列的数据格式设置表达式中填写: {O:p} 就可以得到带两们小数的百分数了
      

  5.   

    我更想了解第二种方法怎么做,因为公司的报表中会有很多数据上的处理,在这里我只是简单的以PASS/(PASS+FAIL)为代表.还有什么高招吗,谢谢大侠们的帮忙,上头对这个报表已经催了,急啊
      

  6.   

    在SQL2000里写个自定义函数。把Select 语句写成存储过程。然后在里边调用一下自定义函数。(里边取两位小数)
      

  7.   

    哦哦, 不好意思
    ds 指 dataset 
    gz 是你随便写的    Dim cn As SqlConnection
            Dim appName As String
            appName = ConfigurationSettings.AppSettings("strconn")
            cn = New SqlConnection(appName)
            cn.Open()        Dim cmd As New SqlCommand
            Dim da As New SqlDataAdapter
            Dim ds As New DataSet        With cmd
                .Connection = cn
                .CommandType = CommandType.StoredProcedure
                .CommandText = "pro_communion"
            End With        da.SelectCommand = cmd
            da.Fill(ds, "gz")
     
            '设置主题列如果太长用 "…"显示 ,将发布日期设置成组合列
            Dim table As DataTable = ds.Tables("gz")
            table.Columns.Add(New DataColumn("日期", GetType(String)))
            table.Columns.Add(New DataColumn("主题", GetType(String)))        Dim i As Integer
            Dim zt As String
            Dim d1 As Date
            Dim d2 As Date        For i = 0 To table.Rows.Count - 1
                zt = Trim(table.Rows(i).Item("subject"))
                If ch(zt) > 20 Then
                    table.Rows(i).Item("主题") = Left(zt, 18) & "…"
                Else
                    table.Rows(i).Item("主题") = zt
                End If
                d1 = table.Rows(i).Item("createdate")
                d2 = table.Rows(i).Item("lastdate")
                table.Rows(i).Item("日期") = Format(d1, "MM/dd") & "-" & Format(d2, "MM/dd")
            Next        DataGrid1.DataSource = table.DefaultView        '如果删除到最后一个时发生错误,需要判断        Try
                DataGrid1.DataBind()
            Catch exc As System.Web.HttpException
                DataGrid1.CurrentPageIndex = 0
                DataGrid1.DataBind()        End Try
            cn.Close()
            cn = Nothing
            da = Nothing
            ds = Nothing
      

  8.   

    前台
    <asp:BoundColumn DataField="日期" ReadOnly="True" HeaderText="发布日期">
    <ItemStyle HorizontalAlign="Center" Width="160"></ItemStyle>
    </asp:BoundColumn>