selective with search with “MaterialName” and “LoaNo” also “MaterialName” or “LoaNo” on a form, use of table filter(Contractor_filter).
Design sql query for checking balance in respect of received and released on material basis of “MaterialName”,“LoaNo”
Below SQL query design to display Distinct item, so how to filter option applied on below query so that search with “MaterialName” and “LoaNo” Also “MaterialName” or “LoaNo” on a form
SELECT “LoaNo”, “MaterialName”, RECEIVED, RELEASED, RECEIVED - RELEASED BALANCE
FROM (SELECT DISTINCT “LoaNo”, “MaterialName”,
CASEWHEN(“TotalRcvd” IS NULL,0,“TotalRcvd”) RECEIVED,
CASEWHEN(“TotalReleased” IS NULL,0,“TotalReleased”) RELEASED
FROM “Contractor”
LEFT JOIN (SELECT “Type”, “MaterialName”, “LoaNo”,
SUM(“Quantity”) AS “TotalRcvd”
FROM “Contractor”
WHERE “Type” = ‘Recieved’
GROUP BY “MaterialName”, “LoaNo”, “Type”) “a”
ON (“Contractor”.“MaterialName” = “a”.“MaterialName”)
AND “Contractor”.“LoaNo” = “a”.“LoaNo”
LEFT JOIN (SELECT “Type”, “MaterialName”, “LoaNo”,
SUM(“Quantity”) AS “TotalReleased”
FROM “Contractor”
WHERE “Type” = ‘Released’
GROUP BY “MaterialName”, “LoaNo”, “Type”) “b”
ON (“Contractor”.“MaterialName” = “b”.“MaterialName”)
AND “Contractor”.“LoaNo” = “b”.“LoaNo”)
I modified above as
SELECT “Contractor”.“LoaNo”, “Contractor”.“MaterialName”, “RECEIVED”, “RELEASED”, “RECEIVED” - “RELEASED” “BALANCE” FROM ( SELECT DISTINCT “Contractor”.“LoaNo”, “Contractor”.“MaterialName”, CASEWHEN( “TotalRcvd” IS NULL, 0, “TotalRcvd” ) “RECEIVED”, CASEWHEN( “TotalReleased” IS NULL, 0, “TotalReleased” ) “RELEASED” FROM “Contractor”, “Contractor_filter” LEFT JOIN ( SELECT “Contractor”.“Type”, “Contractor”.“MaterialName”, “Contractor”.“LoaNo”, SUM( “Contractor”.“Quantity” ) AS “TotalRcvd” FROM “Contractor”, “Contractor_filter” WHERE “Contractor”.“Type” = ‘Recieved’ GROUP BY “Contractor”.“MaterialName”, “Contractor”.“LoaNo”, “Contractor”.“Type” ) “a” ON ( “Contractor”.“MaterialName” = “a”.“MaterialName” ) AND “Contractor”.“LoaNo” = “a”.“LoaNo” LEFT JOIN ( SELECT “Contractor”.“Type”, “Contractor”.“MaterialName”, “Contractor”.“LoaNo”, SUM( “Contractor”.“Quantity” ) AS “TotalReleased” FROM “Contractor”,“Contractor_filter” WHERE “Contractor”.“Type” = ‘Released’ GROUP BY “Contractor”.“MaterialName”, “Contractor”.“LoaNo”, “Contractor”.“Type” ) “b” ON ( “Contractor”.“MaterialName” = “b”.“MaterialName” ) AND “Contractor”.“LoaNo” = “b”.“LoaNo” ) WHERE ( ( UPPER ( “Contractor”.“MaterialName” ) LIKE ‘%’ || UPPER ( “Contractor_filter”.“MaterialName” ) || ‘%’ ) OR ( “Contractor_filter”.“MaterialName” IS NULL ) ) And ( ( UPPER ( “Contractor”.“LoaNo” ) LIKE ‘%’ || UPPER ( “Contractor_filter”.“LoaNo” ) || ‘%’ ) OR ( “Contractor_filter”.“LoaNo” IS NULL ) )
showing error
User lack privilage or objectnot found “Contractor”.“MaterialName”
so guide me for this