SQLTeam.com | Weblogs | Forums

PROBLEM with SUM

Good afternoon, I have a question:

In the table below, we have the employees' salaries in the column (SAL) and the accumulated salaries in the other, my question is how can I get the column of salaries (SAL) from the column of cumulative salaries.

EMP A B C D

SAL 10 15 20 5

SAL_ACUM 10 25 45 50

Hi

By
subtracting
each value from previous value
Of cumulative sum column

25 - 10
15

45 - 25
20

50 - 45
5

But with a query. And imagine i just have the the SAL_ACUM

please provide proper sample data

declare @ale table(col1 int)
insert into @ale
select 1

--etc for all your columns and data points

help us help you

The data for my exercise is here :


and what i want is : The total number of confirmed cases per province or, when not
available, by country .
Can you help me ?
i tried this , but isnt right because in this case i cant do the SUM
Select SUM (Confirmed),Province_State,Country_Region
from world_health_i1160437.covid_19
Group by Province_State,Country_Region

I will be happy to help you. Once you get us the data in the format you were requested to give it in?

Not going to retype all of that data in the image for you and also give you an answer. Help us help you. We cant see or access your database so you will have to provide not an image but DDL and DML

Thank you so much my data set is in the link bellow


And what i need is

  1. the total number of confirmed cases per province or, when not available, by country .

again, please provide that data not as a csv but as proper DDL and DML

the site doesnt let me to put it here, but anyways thanks

declare @paleale table(SNO int, ObservationDate date, Province varchar(150),
Country nvarchar(50), LastUpdate Datetime, 
Confirmed decimal(10,3), Deaths decimal(10,3)
)

insert into @paleale 
select 1, '2020-01-22', 'Anhui', 'Mainland China', '2020-01-22 17:00', 1.0, 0.0 union all
---next row
--next row
--your whole csv, type it out as above

hi

what do you mean by ? i cant do the SUM

the below should work
Select
SUM (Confirmed)
, Province_State
, Country_Region
from
world_health_i1160437.covid_19
Group by
Province_State
, Country_Region

what does this mean ?
The total number of confirmed cases per province or, when not
available, by country .

Looks very easy to do .. if you can explain ..

hi
i think the sum doest work because the number of confirmed cases is cumulative
for example, in the day 1 there are 20 cases and in the day 2 there are 30. it means that there are (20+10) cases in total

then take the last record .. it will have the sum of all confirmed cases combined