Question:- Create a database and make a table “employee”.
empid, empname, address, dob, salary
a) Insert 5 records.
b) Make a query to display the list of employees whose age is more than 25 years.
Solution:-
a) To create a database and make a employee table.
Step 1:- Start Ms Access app.
Step 2:- Rename the database as “employee”. Click Create to finish naming the database.
Step 3:- To add more fields to a table in Datasheet view, double-click the Add New Field header.
Step 4:- Next, we've added the fields empid, empname, address, dop and salary to the employee table.
Step 5:- Next, select Save table from the menu. The Save As dialog box will appear to let you save the table name “employee”.
Step 6:- Insert suitable 5 records in table and save table.
b) To create a required query
Step 1:- Select the Create tab. Then click on the Query Design button under the Other group.
Step 2:- Next, highlight the employee table and clicked on the Add button. When you are done selecting the tables, click on the Close button.
Step 3:- Add the fields to the query. You can do this by double-clicking on the field name. In this example, we've added the Product Name and Product Amount.
Step 4:- Then click on the Save button at the top left of the window.
Step 5:- The Save As window should appear. Enter the name “employeeage” and click on the OK button.
Step 6:- Click on Total button under Show/Hide Group in Design Tab.
Step 7:- In the Age field, type
Age: DateDiff("yyyy",[DOB],Now())+Int(Format(Now(),"mmdd")<Format([DOB],"mmdd"))
Step 8:- In the Criteria of age field type >25.
Step 9:- That’s all the steps for displaying employees of whose age is greater than 25.
No comments:
Post a Comment