476,907 views
11 votes
11 votes
write the sql code to generate the total hours worked and the total charges made by all employees . the results are shown in fig.P7.8

User Jameo
by
2.9k points

2 Answers

16 votes
16 votes

The SQL code to generate the total hours worked and the total charges made by all employees would be:

SELECT employee_id, SUM(hours_worked) AS total_hours_worked

FROM the_hours_worked_table

GROUP BY employee_id;

How to write an SQL code

To write an SQL code, start with the SELECT clause to specify the columns you want to retrieve from the tables. Follow with the FROM clause to identify the tables containing the relevant data.

Use the WHERE clause to filter the data based on specific conditions. Combine data from multiple tables based on relationships with the JOIN clause.

write the sql code to generate the total hours worked and the total charges made by-example-1
User Binit Singh
by
2.8k points
9 votes
9 votes

Answer:

Select SUM(HOURS), SUM(CHARGES) from employees

Step-by-step explanation:

The table structure is not given. So, I will assume that the table name is "employees", the columns to retrieve are "hours" and "charges"

Having said that, the function to retrieve the total of column is the sum() function.

So, the query is as follows:

Select ----> This means that the query is to retrieve from the table

SUM(HOURS), SUM(CHARGES) --- This represent the records to retrieve

from employees ---- This represents the table to retrieve from.

User Oazabir
by
2.8k points