sqlcrystal-reportsssms-16

SAP Crystal reports


I have department Name columns as five records: 1.tyre 2.tank 3.wheel 4.paint 5.engine

I need the SQL query When I select all the above mentioned department at the same time to display all the records it should display as (ALL Departments)

Column Name-DeptName(if i select all the department it should show deptname as All Departments) Example: DeptName-All Departments


Solution

  • I assume you have a multi-value parameter for the user to select departments.

    Create and use a formula based on that parameter like this:

    IF "tyre" in {?Dept}
    AND "tank" in {?Dept}
    AND "wheel" in {?Dept}
    AND "paint" in {?Dept}
    AND "engine" in {?Dept}
    Then "ALL Dept" ELSE {yourDepartmentDatabaseColumn} ;