%3CLINGO-SUB%20id%3D%22lingo-sub-1573509%22%20slang%3D%22en-US%22%3EUse%20Synapse%20SQL%20to%20find%20COVID%20hotspots%20in%20the%20world%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1573509%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Foverview-what-is%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Synapse%20Analytics%3C%2FA%3E%26nbsp%3Bis%20a%20limitless%20data%20analytics%20service%20that%20enables%20you%20to%20analyze%20data%20on%20Azure%20Data%20Lake%20storage.%20It%20provides%20managed%20Apache%20Spark%20and%20T-SQL%20engines%20(%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql-data-warehouse%2Fsql-data-warehouse-overview-what-is%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eprovisioned%3C%2FA%3E%26nbsp%3Band%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fsql%2Fon-demand-workspace-overview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eserverless%3C%2FA%3E)%20for%20analyzing%20data.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20article%2C%20you%20will%20see%20how%20you%20can%20find%20the%20countries%20with%20highest%20weekly%20increase%20of%20COVID%20cases%20by%20analyzing%20data%20from%20the%20parquet%20files%20stored%20on%20Azure%20storage%20using%20Synapse%20SQL%20endpoint%20in%20Synapse%20Analytics.%20Synapse%20SQL%20engine%20is%20the%20perfect%20choice%20for%20ad-hoc%20data%20analytics%20for%20the%20data%20analysts%20with%20T-SQL%20skills.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1295390891%22%20id%3D%22toc-hId--1295390891%22%3EPrerequisite%3C%2FH2%3E%0A%3CP%3ETo%20try%20this%20sample%2C%20you%20need%20to%20have%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fquickstart-create-workspace%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Synapse%20Analytics%20workspace%3C%2FA%3E.%20If%20you%20don%E2%80%99t%20have%20one%20you%20can%20easily%20deploy%20it%20using%26nbsp%3B-ERR%3AREF-NOT-FOUND-Azure%20portal%26nbsp%3Bor%20this%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fsynapse-analytics%2Fquickstart-create-workspace%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EDeployment%20template%3C%2FA%3E.%20Workspace%20automatically%20deploys%20one%20serverless%20Synapse%20SQL%20endpoint%20that%20is%20everything%20we%20need%20for%20this%20kind%20of%20analysis.%20With%20the%20workspace%20you%20are%20also%20getting%20easy-to-use%20Web%20UI%20called%20Synapse%20Studio%20that%20enables%20you%20to%20start%20analyzing%20the%20files%20directly%20from%20your%20browser.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CEM%3ENOTE%3A%20You%20need%20Synapse%20SQL%26nbsp%3B-ERR%3AREF-NOT-FOUND-serverless%26nbsp%3B(on-demand)%20query%20endpoint%20to%20execute%20the%20code%20in%20this%20article.%20The%20functionalities%20used%20in%20this%20article%20are%20still%20not%20available%20in%26nbsp%3B-ERR%3AREF-NOT-FOUND-provisioned%E2%80%AF%20endpoint.%3C%2FEM%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1192121942%22%20id%3D%22toc-hId-1192121942%22%3ECOVID%20data%20set%3C%2FH2%3E%0A%3CP%3EIn%20this%20sample%20is%20used%20the%20latest%20available%20public%20data%20on%20geographic%20distribution%20of%20COVID-19%20cases%20worldwide%20from%20the%26nbsp%3B-ERR%3AREF-NOT-FOUND-European%20Center%20for%20Disease%20Prevention%20and%20Control%20(ECDC).%20Each%20row%2Fentry%20contains%20the%20number%20of%20new%20cases%20reported%20per%20day%20and%20per%20country.%20For%20more%20information%20about%20this%20dataset%2C%20see%26nbsp%3B%5B%23%24dp17%5D%3CA%20href%3D%22https%3A%2F%2Fwww.ecdc.europa.eu%2Fen%2Fpublications-data%2Fdownload-todays-data-geographic-distribution-covid-19-cases-worldwide%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%20Data%20set%20is%20updated%20on%20daily%20basis%20and%20placed%20as%20a%20part%20of%26nbsp%3B-ERR%3AREF-NOT-FOUND-Azure%20Open%20Dataset.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--615332521%22%20id%3D%22toc-hId--615332521%22%3EData%20exploration%20with%20OPENROWSET%20function%3C%2FH2%3E%0A%3CP%3ESynapse%20SQL%20endpoint%20in%20Synapse%20Analytics%20enables%20you%20to%20use%26nbsp%3B-ERR%3AREF-NOT-FOUND-OPENROWSET%26nbsp%3BT-SQL%20function%20to%20analyze%20data%20in%20Azure%20Data%20Lake%20storage.%20This%20is%20easy%20to%20use%20function%20where%20you%20just%20need%20to%20provide%20URL%20of%20some%20file%20on%20Azure%20storage%20and%20you%20will%20get%20the%20content%20of%20the%20file.%20Example%20of%26nbsp%3B-ERR%3AREF-NOT-FOUND-OPENROWSET%26nbsp%3Bfunction%20that%20reads%20the%20content%20of%20a%20parquet%20file%20placed%20on%20Azure%20storage%20is%20shown%20in%20the%20following%20example%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_0-1596820999787.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211013iF8E5D014E43F42A0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_0-1596820999787.png%22%20alt%3D%22JovanPop_0-1596820999787.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20provide%20a%20file%20URL%20after%20the%26nbsp%3B%3CSTRONG%3Ebulk%3C%2FSTRONG%3E%26nbsp%3Bkeyword%20and%20specify%20that%20you%20are%20using%20parquet%20format%2C%20you%20will%20get%20the%20content%20of%20that%20parquet%20file.%20In%20this%20result%20set%20we%20can%20see%20some%20interesting%20columns%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Edate_rep%20%E2%80%93%20date%20when%20the%20COVID%20cases%20are%20reported.%3C%2FLI%3E%0A%3CLI%3Ecountries_and_territories%2Fgeo_id%20identifies%20the%20country%20where%20the%20COVID%20cases%20are%20reported.%3C%2FLI%3E%0A%3CLI%3Ecases%20%E2%80%93%20number%20of%20reported%20cases%20in%20the%20country%20on%20a%20date_rep%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1872180312%22%20id%3D%22toc-hId-1872180312%22%3ECurrent%20and%20past%20week%20cases%20per%20country%3C%2FH2%3E%0A%3CP%3EWe%20can%20easily%20get%20the%20number%20of%20cases%20reported%20for%20each%20country%20on%20a%20given%20day.%20TSQL%20LAG%20function%20enables%20us%20to%20get%20the%20number%20of%20cases%20reported%207%20days%20ago%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_1-1596820999808.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211014iDBC6BEF98964BF07%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_1-1596820999808.png%22%20alt%3D%22JovanPop_1-1596820999808.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELAG%20function%20will%20return%20a%20value%20of%20COVID%20cases%20reported%20in%20the%20record%20with%20the%20same%20geo_id%20(see%20PARTITION%20BY%20geo_id%20in%20OVER%20clause)%20column%2C%20and%20return%207%3CSUP%3Eth%3C%2FSUP%3E%20previous%20record%20ordered%20by%20date_rep%20(see%20ORDER%20BY%20date_rep%20in%20OVER%20clause).%20This%20is%20the%20number%20of%20cases%20reported%20seven%20days%20ago%20in%20the%20country.%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20see%20on%20the%20picture%20above%20in%20Finland%20is%20reported%2029%20cases%20on%206%3CSUP%3Eth%3C%2FSUP%3E%20august%2C%20and%2010%20cases%20seven%20days%20before.%20This%20is%20exactly%20what%20we%20need%20to%20have%20to%20compare%20currently%20reported%20number%20of%20cases%20with%20the%20number%20of%20cases%20reported%20seven%20days%20ago%20to%20calculate%20the%20increase%20per%20each%20year.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-64725849%22%20id%3D%22toc-hId-64725849%22%3EAverage%20weekly%20cases%3C%2FH2%3E%0A%3CP%3ENumber%20of%20COVID%20cases%20might%20vary%20if%20we%20look%20at%20daily%20values.%20In%20some%20cases%2C%20you%20can%20see%20daily%20variations%20like%2010%2C%2023%2C%209%2C%2017%20that%20might%20provide%20misleading%20conclusions%20especially%20if%20the%20variation%20is%20close%20to%20actual%20value.%3C%2FP%3E%0A%3CP%3EMore%20reliable%20metric%20would%20be%20to%20calculate%20average%20number%20of%20reported%20cases%20per%20week%20(or%20any%207-day%20time%20window).%20We%20can%20use%20windowing%20extension%20of%20AVG%20function%20for%20this%20purpose%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3EAVG(%3CVALUE%3E)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3B%3CPARITITION%20value%3D%22%22%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3Border%26nbsp%3Bby%26nbsp%3B%3CSORT%20value%3D%22%22%3E%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%26nbsp%3BROWS%26nbsp%3BBETWEEN%26nbsp%3B%3CSTART%3E%20AND%26nbsp%3B%3CEND%3E%26nbsp%3B%26nbsp%3B)%3C%2FEND%3E%3C%2FSTART%3E%3C%2FSORT%3E%3C%2FPARITITION%3E%3C%2FVALUE%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20each%20record%20this%20window%20function%20will%20get%20the%20records%20that%20have%20the%20same%20%3CPARTITION%20value%3D%22%22%3E%20(for%20example%20country%20id%20since%20we%20are%20finding%20average%20value%20within%20the%20country)%2C%20order%20them%20by%20%3CSORT%20value%3D%22%22%3E%20(for%20example%20date%20when%20the%20cases%20are%20reported)%2C%20and%20get%20the%20records%20between%20%3CSTART%3E%20and%20%3CEND%3E%20in%20this.%20Then%20it%20will%20calculate%20average%20value%20(for%20example%20cases%20in%20our%20case).%3C%2FEND%3E%3C%2FSTART%3E%3C%2FSORT%3E%3C%2FPARTITION%3E%3C%2FP%3E%0A%3CP%3EYou%20can%20find%20more%20information%20about%20window%20function%20in%20the%20article%26nbsp%3B-ERR%3AREF-NOT-FOUND-Advanced%20analytics%20of%20COVID%20data%20using%20Synapse%20SQL%20endpoint.%3C%2FP%3E%0A%3CP%3EThe%20following%20query%20returns%20average%20number%20of%20reported%20cases%20in%20past%20seven%20days%20and%20the%20average%20number%20of%20cases%20in%20previous%207-day%20period%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_2-1596820999832.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211015iD48E100C010290FC%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_2-1596820999832.png%22%20alt%3D%22JovanPop_2-1596820999832.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ENow%20we%20have%20reports%20with%20the%20data%20like%20the%20previous%20case%2C%20but%20more%20reliable%20metric.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1742728614%22%20id%3D%22toc-hId--1742728614%22%3EThe%20countries%20with%20the%20highest%20increase%20of%20COVID%20cases%3C%2FH2%3E%0A%3CP%3EWe%20have%20information%20about%20the%20countries%2C%20number%20of%20reported%20cases%20this%20week%2C%20and%20number%20of%20reported%20cases%20a%20week%20ago%2C%20so%20we%20are%20ready%20to%20compare%20these%20values%20and%20find%20the%20countries%20with%20the%20highest%20increase%20of%20COVID%20cases.%3C%2FP%3E%0A%3CP%3EI%20will%20put%20the%20query%20that%20returns%20average%20weekly%20cases%20as%20CTE%20named%20query%2C%20and%20do%20analyze%20data%20on%20the%20result%20of%20this%20named%20query%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22JovanPop_3-1596820999861.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F211016i503EDA00840682D7%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22JovanPop_3-1596820999861.png%22%20alt%3D%22JovanPop_3-1596820999861.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20filtering%20results%20on%20some%20specific%20date%20(5%3CSUP%3Eth%3C%2FSUP%3E%26nbsp%3BAugust)%2C%20ignoring%20countries%20with%20less%20than%20100%20cases%2C%20and%20ordering%20by%20percentage%20of%20increase.%20You%20can%20see%20the%20results%20with%20the%20countries%20where%20the%20number%20of%20COVID%20cases%20is%20increased.%20You%20can%20easily%20modify%20that%20report%20to%20change%20time%20periods%20or%20get%20the%20report%20for%20some%20point%20in%20time%20in%20the%20past.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-744784219%22%20id%3D%22toc-hId-744784219%22%3EConclusion%3C%2FH2%3E%0A%3CP%3ESynapse%20SQL%20endpoint%20and%20Synapse%20Studio%20in%20Azure%20Synapse%20Analytics%20are%20tools%20for%20easy%20data%20exploration%20that%20enable%20you%20to%20easily%20read%20the%20content%20of%20a%20file%20and%20do%20basic%20data%20exploration.%20In%20this%20example%2C%20we%20have%20seen%20how%20to%20leverage%20T-SQL%20language%20and%20charting%20features%20in%20Synapse%20Analytics%20to%20identify%20the%20countries%20with%20highest%20weekly%20increase%20of%20COVID%20cases.%20The%20similar%20analysis%20can%20be%20repeated%20on%20any%20other%20data%20set.%20You%20can%20find%20more%20information%20about%20querying%20files%20in%20Azure%20Data%20Lakes%20Storage%20in%20this%26nbsp%3B-ERR%3AREF-NOT-FOUND-article.%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20to%20try%20these%20queries%2C%20the%20scripts%20are%20below%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3Eselect%26nbsp%3Btop%26nbsp%3B10%26nbsp%3B%26nbsp%3B*%0Afrom%26nbsp%3Bopenrowset(bulk%26nbsp%3B'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bformat%3D'parquet')%26nbsp%3Bas%26nbsp%3Ba%3B%0A%0Aselect%26nbsp%3B%26nbsp%3BTOP%26nbsp%3B10%26nbsp%3Bdate_rep%2C%26nbsp%3Bcountries_and_territories%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcases%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bprev%26nbsp%3B%3D%26nbsp%3BLAG(CASES%2C%26nbsp%3B7)%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3Bgeo_id%26nbsp%3Border%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3B)%0Afrom%26nbsp%3Bopenrowset(bulk%26nbsp%3B'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bformat%3D'parquet')%26nbsp%3Bas%26nbsp%3Ba%0Aorder%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3Bdesc%3B%0AGO%0A%0Aselect%26nbsp%3B%26nbsp%3BTOP%26nbsp%3B10%26nbsp%3Bdate_rep%2C%26nbsp%3Bcountries_and_territories%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcurrent_avg%26nbsp%3B%3D%26nbsp%3BAVG(CASES)%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3Bgeo_id%26nbsp%3Border%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3BROWS%26nbsp%3BBETWEEN%26nbsp%3B7%26nbsp%3BPRECEDING%26nbsp%3BAND%26nbsp%3BCURRENT%26nbsp%3BROW%26nbsp%3B%26nbsp%3B)%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bprev_avg%26nbsp%3B%3D%26nbsp%3BAVG(CASES)%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3Bgeo_id%26nbsp%3Border%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3BROWS%26nbsp%3BBETWEEN%26nbsp%3B14%26nbsp%3BPRECEDING%26nbsp%3BAND%26nbsp%3B7%26nbsp%3BPRECEDING%26nbsp%3B%26nbsp%3B)%0Afrom%26nbsp%3Bopenrowset(bulk%26nbsp%3B'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bformat%3D'parquet')%26nbsp%3Bas%26nbsp%3Ba%0Aorder%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3Bdesc%3B%0AGO%0Awith%26nbsp%3Bweekly_cases%26nbsp%3Bas%26nbsp%3B(%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bselect%26nbsp%3B%26nbsp%3Bgeo_id%2C%26nbsp%3Bdate_rep%2C%26nbsp%3Bcountries_and_territories%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bcurrent_avg%26nbsp%3B%3D%26nbsp%3BAVG(CASES)%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3Bgeo_id%26nbsp%3Border%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3BROWS%26nbsp%3BBETWEEN%26nbsp%3B7%26nbsp%3BPRECEDING%26nbsp%3BAND%26nbsp%3BCURRENT%26nbsp%3BROW%26nbsp%3B%26nbsp%3B)%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bprev_avg%26nbsp%3B%3D%26nbsp%3BAVG(CASES)%26nbsp%3BOVER(partition%26nbsp%3Bby%26nbsp%3Bgeo_id%26nbsp%3Border%26nbsp%3Bby%26nbsp%3Bdate_rep%26nbsp%3BROWS%26nbsp%3BBETWEEN%26nbsp%3B14%26nbsp%3BPRECEDING%26nbsp%3BAND%26nbsp%3B7%26nbsp%3BPRECEDING%26nbsp%3B%26nbsp%3B)%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bfrom%26nbsp%3Bopenrowset(bulk%26nbsp%3B'https%3A%2F%2Fpandemicdatalake.blob.core.windows.net%2Fpublic%2Fcurated%2Fcovid-19%2Fecdc_cases%2Flatest%2Fecdc_cases.parquet'%2C%0A%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3Bformat%3D'parquet')%26nbsp%3Bas%26nbsp%3Ba%26nbsp%3B)%0Aselect%26nbsp%3Bcountries_and_territories%2C%26nbsp%3Bcurrent_avg%2C%26nbsp%3Bprev_avg%2C%26nbsp%3B%5BWoW%25%5D%26nbsp%3B%3D%26nbsp%3B100*(1.*%26nbsp%3Bcurrent_avg%26nbsp%3B%2F%26nbsp%3Bprev_avg%26nbsp%3B-%26nbsp%3B1)%0Afrom%26nbsp%3Bweekly_cases%0Awhere%26nbsp%3Bdate_rep%26nbsp%3B%3D%26nbsp%3B'2020-08-05'%0Aand%26nbsp%3Bprev_avg%26nbsp%3B%26gt%3B%26nbsp%3B100%0Aorder%26nbsp%3Bby%26nbsp%3B(1.%26nbsp%3B*%26nbsp%3Bcurrent_avg%26nbsp%3B%2F%26nbsp%3Bprev_avg%26nbsp%3B-1)%26nbsp%3B%26nbsp%3Bdesc%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1573509%22%20slang%3D%22en-US%22%3E%3CP%3ESynapse%20SQL%20query%20engine%20enables%20you%20to%20run%20complex%20queries%20and%20build%20powerful%20reports.%20Here%20you%20will%20learn%20how%20to%20find%20the%20countries%20where%20the%20number%20of%20COVID%20cases%20is%20increased%20compared%20to%20the%20previous%20week.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1573509%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20SQL%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20Studio%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

Azure Synapse Analytics is a limitless data analytics service that enables you to analyze data on Azure Data Lake storage. It provides managed Apache Spark and T-SQL engines (provisioned and serverless) for analyzing data. 

In this article, you will see how you can find the countries with highest weekly increase of COVID cases by analyzing data from the parquet files stored on Azure storage using Synapse SQL endpoint in Synapse Analytics. Synapse SQL engine is the perfect choice for ad-hoc data analytics for the data analysts with T-SQL skills.

 

Prerequisite

To try this sample, you need to have Azure Synapse Analytics workspace. If you don’t have one you can easily deploy it using Azure portal or this Deployment template. Workspace automatically deploys one serverless Synapse SQL endpoint that is everything we need for this kind of analysis. With the workspace you are also getting easy-to-use Web UI called Synapse Studio that enables you to start analyzing the files directly from your browser.

NOTE: You need Synapse SQL serverless (on-demand) query endpoint to execute the code in this article. The functionalities used in this article are still not available in provisioned  endpoint.

 

COVID data set

In this sample is used the latest available public data on geographic distribution of COVID-19 cases worldwide from the European Center for Disease Prevention and Control (ECDC). Each row/entry contains the number of new cases reported per day and per country. For more information about this dataset, see here. Data set is updated on daily basis and placed as a part of Azure Open Dataset.

 

Data exploration with OPENROWSET function

Synapse SQL endpoint in Synapse Analytics enables you to use OPENROWSET T-SQL function to analyze data in Azure Data Lake storage. This is easy to use function where you just need to provide URL of some file on Azure storage and you will get the content of the file. Example of OPENROWSET function that reads the content of a parquet file placed on Azure storage is shown in the following example:

 

JovanPop_0-1596820999787.png

 

If you provide a file URL after the bulk keyword and specify that you are using parquet format, you will get the content of that parquet file. In this result set we can see some interesting columns:

  • date_rep – date when the COVID cases are reported.
  • countries_and_territories/geo_id identifies the country where the COVID cases are reported.
  • cases – number of reported cases in the country on a date_rep

 

Current and past week cases per country

We can easily get the number of cases reported for each country on a given day. TSQL LAG function enables us to get the number of cases reported 7 days ago:

JovanPop_1-1596820999808.png

 

LAG function will return a value of COVID cases reported in the record with the same geo_id (see PARTITION BY geo_id in OVER clause) column, and return 7th previous record ordered by date_rep (see ORDER BY date_rep in OVER clause). This is the number of cases reported seven days ago in the country.

As you can see on the picture above in Finland is reported 29 cases on 6th august, and 10 cases seven days before. This is exactly what we need to have to compare currently reported number of cases with the number of cases reported seven days ago to calculate the increase per each year.

 

Average weekly cases

Number of COVID cases might vary if we look at daily values. In some cases, you can see daily variations like 10, 23, 9, 17 that might provide misleading conclusions especially if the variation is close to actual value.

More reliable metric would be to calculate average number of reported cases per week (or any 7-day time window). We can use windowing extension of AVG function for this purpose:

 

 

AVG(<value>)
       OVER(partition by <paritition value>
            order by <sort value>
            ROWS BETWEEN <start> AND <end>  )

 

 

For each record this window function will get the records that have the same <partition value> (for example country id since we are finding average value within the country), order them by <sort value> (for example date when the cases are reported), and get the records between <start> and <end> in this. Then it will calculate average value (for example cases in our case).

You can find more information about window function in the article Advanced analytics of COVID data using Synapse SQL endpoint.

The following query returns average number of reported cases in past seven days and the average number of cases in previous 7-day period:

JovanPop_2-1596820999832.png

Now we have reports with the data like the previous case, but more reliable metric.

 

The countries with the highest increase of COVID cases

We have information about the countries, number of reported cases this week, and number of reported cases a week ago, so we are ready to compare these values and find the countries with the highest increase of COVID cases.

I will put the query that returns average weekly cases as CTE named query, and do analyze data on the result of this named query:

JovanPop_3-1596820999861.png

I’m filtering results on some specific date (5th August), ignoring countries with less than 100 cases, and ordering by percentage of increase. You can see the results with the countries where the number of COVID cases is increased. You can easily modify that report to change time periods or get the report for some point in time in the past.

 

Conclusion

Synapse SQL endpoint and Synapse Studio in Azure Synapse Analytics are tools for easy data exploration that enable you to easily read the content of a file and do basic data exploration. In this example, we have seen how to leverage T-SQL language and charting features in Synapse Analytics to identify the countries with highest weekly increase of COVID cases. The similar analysis can be repeated on any other data set. You can find more information about querying files in Azure Data Lakes Storage in this article.

If you want to try these queries, the scripts are below:

 

 

 

select top 10  *
from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet',
                format='parquet') as a;

select  TOP 10 date_rep, countries_and_territories,
        cases,
        prev = LAG(CASES, 7) OVER(partition by geo_id order by date_rep )
from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet',
                        format='parquet') as a
order by date_rep desc;
GO

select  TOP 10 date_rep, countries_and_territories,
        current_avg = AVG(CASES) OVER(partition by geo_id order by date_rep ROWS BETWEEN 7 PRECEDING AND CURRENT ROW  ),
        prev_avg = AVG(CASES) OVER(partition by geo_id order by date_rep ROWS BETWEEN 14 PRECEDING AND 7 PRECEDING  )
from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet',
                 format='parquet') as a
order by date_rep desc;
GO
with weekly_cases as (
        select  geo_id, date_rep, countries_and_territories,
                current_avg = AVG(CASES) OVER(partition by geo_id order by date_rep ROWS BETWEEN 7 PRECEDING AND CURRENT ROW  ),
                prev_avg = AVG(CASES) OVER(partition by geo_id order by date_rep ROWS BETWEEN 14 PRECEDING AND 7 PRECEDING  )
        from openrowset(bulk 'https://pandemicdatalake.blob.core.windows.net/public/curated/covid-19/ecdc_cases/latest/ecdc_cases.parquet',
                             format='parquet') as a )
select countries_and_territories, current_avg, prev_avg, [WoW%] = 100*(1.* current_avg / prev_avg - 1)
from weekly_cases
where date_rep = '2020-08-05'
and prev_avg > 100
order by (1. * current_avg / prev_avg -1)  desc