-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInsertData.sql
More file actions
34 lines (25 loc) · 1.06 KB
/
InsertData.sql
File metadata and controls
34 lines (25 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
bulk insert Activities from 'C:\Users\Simone\Google Drive\Monica\data\attivita-commerciale\attivita_commerciali_geo_CAP.csv'
WITH (
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
ERRORFILE = 'C:\temp\err\myRubbishData.log'
);
bulk insert Crowd from 'C:\Users\Simone\Google Drive\Monica\data\crowd\presenze_sansalvario_19_250318.csv'
WITH (
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n'
--ERRORFILE = 'C:\temp\err\myRubbishData.log'
);
--elab data
/****** Script for SelectTopNRows command from SSMS ******/
SELECT AVG(C1.numero_presenze) as MediaPresenze
FROM [Monica].[dbo].[Crowd] C1
inner join [Monica].[dbo].[Crowd] C2
on C1.data_da = C2.data_da and C1.Cluster = 'Presenze' and C2.Cluster = 'Residenti'
where DATEPART(HOUR, C1.data_da) > 22 or DATEPART(HOUR, C1.data_da) < 2
SELECT AVG(C2.numero_presenze) as MediaResidenti
FROM [Monica].[dbo].[Crowd] C1
inner join [Monica].[dbo].[Crowd] C2
on C1.data_da = C2.data_da and C1.Cluster = 'Presenze' and C2.Cluster = 'Residenti'
where DATEPART(HOUR, C1.data_da) > 22 or DATEPART(HOUR, C1.data_da) < 2