基于询问号码显示网格

时间:2016-01-16 08:08:44

标签: sql asp.net oracle

以下查询显示我想要在网格中显示的结果。

SELECT bb.project_id, bb.building_id, bb.flat_id AS flat_id,
   cc.cust_enq_no AS enquiry_no, cc.NAME enquiry_name,
   TO_CHAR (cc.f_followup_date, 'dd/MM/yyyy') AS last_followup_date,
   cc.f_remarks AS last_followup_comments  FROM xxacl_pn_flat_det_v bb INNER JOIN xxcus.xxacl_pn_customer_enquiry_v cc
   ON bb.project_id = cc.mkey

但我的要求有所改变。

现在,对于每个F_FLAT_ID,有多个CUST_ENQ_NO

Select * from xxcus.xxacl_pn_customer_enquiry_v where F_FLAT_ID = '18158'

它有3条记录。

所以我的第一个查询

  

如何获得多个CUST_ENQ_NO

更新

我想过滤并在网格中显示它

protected void DisplayGridEnquiry()
{
    OracleCommand cmd1 = new OracleCommand("SELECT bb.project_id, bb.building_id, bb.flat_id as FLAT_ID, cc.cust_enq_no as ENQUIRY_NO, " +
                                           "cc.NAME ENQUIRY_NAME, TO_CHAR (cc.f_followup_date,'dd/MM/yyyy') as LAST_FOLLOWUP_DATE, cc.f_remarks AS LAST_FOLLOWUP_COMMENTS " +
                                           "FROM xxacl_pn_flat_det_v bb INNER JOIN xxcus.xxacl_pn_customer_enquiry_v cc " +
                                           "ON bb.project_id = cc.mkey", ObjPriCon);
    DataTable dtfillgrid1 = new DataTable();
    OracleDataAdapter da1 = new OracleDataAdapter(cmd1);
    da1.Fill(dtfillgrid1);

    DataView dView1 = new DataView(dtfillgrid1);
    dView1.RowFilter = "PROJECT_ID = '" + ddlProject.SelectedValue + "' AND BUILDING_ID = '" + ddlBuilding.SelectedValue + "' AND FLAT_ID = '" + ddlUnit.SelectedItem.Text + "'";
    GridEnquiry.DataSource = dView1.ToTable();
    GridEnquiry.DataBind();
}

1 个答案:

答案 0 :(得分:1)

SELECT bb.project_id, bb.building_id, bb.flat_id AS flat_id,
   cc.cust_enq_no AS enquiry_no, cc.NAME enquiry_name,
   TO_CHAR (cc.f_followup_date, 'dd/MM/yyyy') AS last_followup_date,
   cc.f_remarks AS last_followup_comments  
FROM xxacl_pn_flat_det_v bb 
LEFT JOIN xxcus.xxacl_pn_customer_enquiry_v cc ON  bb.flat_id=cc.F_FLAT_ID