Quantcast
Channel: Question and Answer » oracle
Viewing all articles
Browse latest Browse all 717

Incorrect query filter according to the requirement

$
0
0

My requirement wholly depends on the QUERY.

I am filtering my gridview on the basis of three parameters.

  1. Project_name (Always required)

  2. Date (Not always)

  3. Vehicle_No (Not always)

So, What my requirment is,

With project_name either any one can be used for filtering my gridview.

Currently my debugged query works exactly fine for any two parameters.

Below is my debugged query:-

SELECT DISTINCT sv.mkey, vehicle_no,
               TO_CHAR (date_in, 'dd-MM-yyyy')
            || ' & '
            || time_in vehicleindate_time,
               TO_CHAR (date_out, 'dd-MM-yyyy')
            || ' & '
            || time_out vehicleoutdate_time,
            gate_no_in || ' & ' || gate_no_out ingate_outgateno,
            gd.good_type goods_type, net_weight netweight,
               TO_CHAR (challan_date, 'dd-MM-yyyy')
            || ' & '
            || challan_no challandate_no,
            remark_in remarkin, NULL receipt_no, date_in
       FROM xxcus.xxgid_supinv sv,
            xxcus.xx_supinv_goodtype gd,
            xxcus.xxacl_xxgid_user_mst ms
      WHERE (gd.good_type_code(+) = sv.good_type)
        AND (       sv.project_id = '1368'
                AND TO_CHAR (date_in, 'dd-MM-yyyy') = '26-11-2015'
             OR vehicle_no = '0'
            )
        AND sv.delete_flag = 'N'
   ORDER BY date_in DESC, vehicle_no

The above query shows me the exact result for project_name and Date which I entered.

Image 1

But when I add the third parameter say Vehicle_no it doesn’t show the data for that exact vehicle_no it still shows me the same data which I looked for 2 parameters.

Image 2

I am using ORACLE for the database. Kindly help


Viewing all articles
Browse latest Browse all 717

Trending Articles