What are CTE's in SQL
WITH Statements?
What the benefits, limitations and Syntax are
https://www.selectdistinct.co.uk/2023/12/05/how-to-use-a-cte/
#SQL #CTE #SQLWITH #DATA
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxchristinemaritza
Charles WilliamsCS362Unit 3 Discussion Board
Structured Query Language for Data Management 1
Structured Query Language for Data Management 36-04-17
Table of Contents
Phase 1- Database Design and DDL 3
Business Rules & Entity Tables 3
Entity Tables: 4
SQL CODE: 4
Screenshots: 8
Phase 2 – Security and DML 13
Task 1 14
Task 2 15
Task 3 16
Task 4 17
Task 5 18
Phase 3 - DML (Select) and Procedures 19
Task 1 19
Task 2 20
Task 3 21
Task 4 22
Task 5 23
Phase 4 – Architecture, Indexes 27
Step 1: CREATE TABLE [Degrees] 27
Step 2: Re-create ‘Classes’ TABLE to add ‘DegreeID’ column and INSERT 6 classes 29
Step 3: ALTER TABLE [Students] 31
Step 5: DML script to INSERT INTO the ‘Students’ table ‘DegreeID’ data 33
Step 6: Display ERD 36
Phase 5 – Views, Transactions, Testing and Performance 37
References 38
Phase 1- Database Design and DDL
I contracted to design and develop a database for CTU that will store individual and confidential university data. This database is required to give the back-end engineering to a front-end web application with an instinctive User/Interface (U/I) to be utilized by the college HR office. We've chosen to utilize Microsoft SQL Server 2012 given the way of information to be put away because it will be more secure, and it additionally gives a suite of server upkeep apparatuses to be deserted with the IT Department once the database and web application have been tried and acknowledged by college partners.
Amid our preparatory gatherings, CTU's necessities were characterized and enough perused to start making of the database. The accompanying areas contain the business tenets and element tables created amid the preparatory gatherings, and additionally duplicates of all the SQL code used to manufacture the database and make the Entity Relationship Diagram (ERD).
Business Rules & Entity Tables
Business Rules:
· A student has a name, a birth date, and gender.
· You must track the date the student started at the university and his or her current GPA, as well as be able to inactivate him or her without deleting information.
· For advising purposes, store the student's background/bio information. This is like a little story.
· An advisor has a name and an e-mail address.
· Students are assigned to one advisor, but one advisor may service multiple students.
· A class has a class code, name, and description.
· You need to indicate the specific classes a student is taking/has taken at the university. Track the date the student started a specific class and the grade earned in that class.
· Each class that a student takes has 4 assignments. Each assignment is worth 100 points.Entity Tables:
SQL CODE:
Create Database:
CREATE DATABASE [Cameron_CTU]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Cameron_CTU', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL11.SCAMERON_CTU\MSSQL\DATA\Cameron_CTU.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Cameron_CTU_log', FILENAME = N'c:\Progra ...
This presentation features the fundamentals of SQL tunning like SQL Processing, Optimizer and Execution Plan, Accessing Tables, Performance Improvement Consideration Partition Technique. Presented by Alphalogic Inc : https://www.alphalogicinc.com/
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
With SQL server 2014, Microsoft introduced In-Memory OLTP, codename Hekaton.
This technology contains revolutionary concepts for optimizing the performance of OLTP workloads via natively compiled stored procedures,memory optimized tables and much more.
This session will give you an overview of the different aspects of In-memory OLTP and how this is integrated in the SQL server engine.
By giving demo's we will show you what is (im)possible with this new feature and how this really can increase your database performance!
Year on Year comparison by weekday in power BI
A Step by Step guide to avoid potential errors when using SAMEPERIODLASTYEAR and a simple solution to ensure you compare matching weekdays
https://www.selectdistinct.co.uk/2024/04/16/year-on-year-power-bi/
#PowerBI #SAMEPERIODLASTYEAR #DataViz
Sync Your Slicers in Power BI
A Step by Step guide, to keeping separate slicers in sync across different data sets using slicer groups
https://www.selectdistinct.co.uk/2024/03/12/sync_slicers_in_power_bi/
#PowerBI #Slicers #DataViz
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxchristinemaritza
Charles WilliamsCS362Unit 3 Discussion Board
Structured Query Language for Data Management 1
Structured Query Language for Data Management 36-04-17
Table of Contents
Phase 1- Database Design and DDL 3
Business Rules & Entity Tables 3
Entity Tables: 4
SQL CODE: 4
Screenshots: 8
Phase 2 – Security and DML 13
Task 1 14
Task 2 15
Task 3 16
Task 4 17
Task 5 18
Phase 3 - DML (Select) and Procedures 19
Task 1 19
Task 2 20
Task 3 21
Task 4 22
Task 5 23
Phase 4 – Architecture, Indexes 27
Step 1: CREATE TABLE [Degrees] 27
Step 2: Re-create ‘Classes’ TABLE to add ‘DegreeID’ column and INSERT 6 classes 29
Step 3: ALTER TABLE [Students] 31
Step 5: DML script to INSERT INTO the ‘Students’ table ‘DegreeID’ data 33
Step 6: Display ERD 36
Phase 5 – Views, Transactions, Testing and Performance 37
References 38
Phase 1- Database Design and DDL
I contracted to design and develop a database for CTU that will store individual and confidential university data. This database is required to give the back-end engineering to a front-end web application with an instinctive User/Interface (U/I) to be utilized by the college HR office. We've chosen to utilize Microsoft SQL Server 2012 given the way of information to be put away because it will be more secure, and it additionally gives a suite of server upkeep apparatuses to be deserted with the IT Department once the database and web application have been tried and acknowledged by college partners.
Amid our preparatory gatherings, CTU's necessities were characterized and enough perused to start making of the database. The accompanying areas contain the business tenets and element tables created amid the preparatory gatherings, and additionally duplicates of all the SQL code used to manufacture the database and make the Entity Relationship Diagram (ERD).
Business Rules & Entity Tables
Business Rules:
· A student has a name, a birth date, and gender.
· You must track the date the student started at the university and his or her current GPA, as well as be able to inactivate him or her without deleting information.
· For advising purposes, store the student's background/bio information. This is like a little story.
· An advisor has a name and an e-mail address.
· Students are assigned to one advisor, but one advisor may service multiple students.
· A class has a class code, name, and description.
· You need to indicate the specific classes a student is taking/has taken at the university. Track the date the student started a specific class and the grade earned in that class.
· Each class that a student takes has 4 assignments. Each assignment is worth 100 points.Entity Tables:
SQL CODE:
Create Database:
CREATE DATABASE [Cameron_CTU]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'Cameron_CTU', FILENAME = N'c:\Program Files\Microsoft SQL Server\MSSQL11.SCAMERON_CTU\MSSQL\DATA\Cameron_CTU.mdf' , SIZE = 3072KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'Cameron_CTU_log', FILENAME = N'c:\Progra ...
This presentation features the fundamentals of SQL tunning like SQL Processing, Optimizer and Execution Plan, Accessing Tables, Performance Improvement Consideration Partition Technique. Presented by Alphalogic Inc : https://www.alphalogicinc.com/
Clauses in Sql(Structured Query Language), distinct clause, where clause, where clause, order by clause, group by clause, having clause, Relational Database Management System
With SQL server 2014, Microsoft introduced In-Memory OLTP, codename Hekaton.
This technology contains revolutionary concepts for optimizing the performance of OLTP workloads via natively compiled stored procedures,memory optimized tables and much more.
This session will give you an overview of the different aspects of In-memory OLTP and how this is integrated in the SQL server engine.
By giving demo's we will show you what is (im)possible with this new feature and how this really can increase your database performance!
Year on Year comparison by weekday in power BI
A Step by Step guide to avoid potential errors when using SAMEPERIODLASTYEAR and a simple solution to ensure you compare matching weekdays
https://www.selectdistinct.co.uk/2024/04/16/year-on-year-power-bi/
#PowerBI #SAMEPERIODLASTYEAR #DataViz
Sync Your Slicers in Power BI
A Step by Step guide, to keeping separate slicers in sync across different data sets using slicer groups
https://www.selectdistinct.co.uk/2024/03/12/sync_slicers_in_power_bi/
#PowerBI #Slicers #DataViz
Make your Google Search Console Data more useful with Power BI
Here is a simple step by step guide to taking the daily GSC data, smoothing it into weekly summary data and presenting a nice clean report to show progress without all of the noise that the daily data shows
https://www.selectdistinct.co.uk/2024/03/01/using-google-search-console-data-in-power-bi/
#SEO #DataAnalytics #PowerBI #GSC
Data Lake v Data Warehouse
Do you know the difference?
Data lakes and data warehouses are both storage systems for big data, but they have several key differences.
A data lake is designed to store raw data of all types, including structured, semi-structured, and unstructured data. It’s a great option for companies that benefit from raw data for machine learning.
A data warehouse is designed to be a repository for already structured data to be queried and analysed for very specific purposes. It’s a better fit for companies whose business analysts need to decipher analytics in a structured system.
Understanding these key differences is important for any aspiring data professional
https://www.selectdistinct.co.uk/2024/01/02/difference-between-a-data-lake-and-a-data-warehouse/
#datawarehouse #datalake #dataanalytics
How to create a drop down list in Excel
Use this feature to help get your data input right at source, with built in data validation and in cell drop down
Limit the amount of spelling variations, inconsistencies and errors in Excel
https://www.selectdistinct.co.uk/2024/01/02/dropdown-lists-in-excel/
#Excel #dropdown #datavalidation
Top 5 SQL tips 2023
Presenting our most popular SQL tips for 2023
1. How to calculate running totals in SQL server
2. How to use the LEAD and LAG functions in SQL
3. Group by ROLLUP in SQL
4. Divide by Zero Errors
5. How to split a column in SQL Server
https://www.selectdistinct.co.uk/2023/12/19/top-sql-tips-for-2023/
#SQL #businessanalytics #data #analytics #sqltips
Top 5 Power Bi tips 2023
Presenting our most popular Power BI tips for 2023
1. Show values in Rows
2. Use SAMEPERIODLASTYEAR
3. How to sort dates properly
4. Toggle Measures with SWITCH
5. Advanced TOPN filter
https://www.selectdistinct.co.uk/2023/12/18/top-power-bi-tips-for-2023/
#PowerBI #dataviz #businessanalytics #data #analytics
Music by www.bensound.com
Do you know the difference between calculated columns and measures in Power BI?
In this article, you’ll learn what calculated columns and measures are, how they work, and when to use them.
You’ll also get some tips and best practices for choosing between them.
https://www.selectdistinct.co.uk/2023/11/21/calculated-columns-and-measures-in-power-bi/
#powerBI #measures #calculatedcolumns
Divide by zero errors and how to avoid them
Examples and code samples for SQL, Big Query, Excel, Power BI including DAX and Power Query
https://www.selectdistinct.co.uk/2023/11/01/divide-by-zero-errors/
#dividebyzero #SQL #PowerBI
music by www.bensound.com
How to choose between DAX, Power Query or SQL
to transform data for your Power BI reporting
https://www.selectdistinct.co.uk/2023/10/25/when-to-transform-data/
#powerbi #DAX #PowerQuery
KPIs in Power BI are a great way to focus attention on what matters
This step by step guide shows you how to set them up with tips on their best use
https://www.selectdistinct.co.uk/2023/10/18/power-bi-kpis/
#powerbi #KPIs #dataviz
Need to show the direction of travel on a map in Power BI
We had a client which needed us to do this very thing
This short guide shows how to do it using the Icon Map
https://www.selectdistinct.co.uk/2023/10/11/direction-of-travel-on-a-map-in-power-bi/
#PowerBI #IconMap #businessintelligence
How to combine data tables in DAX in Power BI using the UNION command
This guide shows you how to create a seamless data set from 2 or more tables to make further analysis and reporting much easier
https://www.selectdistinct.co.uk/2023/10/04/union-in-dax/
#PowerBI #DAX #UNION
Combine data sets with APPEND in Power Query
You can use this simple technique to consolidate data from different sources into a single data set to make analysis easier
This is useful if you can't combine the data at source or if you dont have the facility
https://www.selectdistinct.co.uk/2023/09/27/append-data-in-power-query/
#PowerQuery #Append #PowerBI
Connect Power BI to Google BigQuery
Use the public datasets to develop your skills and demonstrate the power of both platforms for FREE
In this example we use the actual wholesale sales data for the US state of Iowa that is one of the public datasets
https://www.selectdistinct.co.uk/2023/09/07/connect-power-bi-to-google-big-query/
This is a great starting point for anyone wanting to build their skills with data that can be refreshed
#PowerBI #BigQuery #PublicData
Easily add subtotals into your queries with the Group by ROLLUP clause in SQL server
We explain the syntax, the logic, and the benefits of using ROLLUP to create subtotals and grand totals in your queries. With examples you can follow
https://www.selectdistinct.co.uk/2023/08/23/group-by-rollup-in-sql-server
#ROLLUP #SQL #DATAANALYTICS
Advanced Top N in Power BI
Here we set up a slicer to define how many Top items we want to see, but importantly classify the rest as 'Others'
This allows us to see the whole picture and focus on the leading items
https://www.selectdistinct.co.uk/2023/07/27/advanced-top-n-filter-power-bi/
#PowerBI #TOPN #DataVisualisation
Power BI comes ready loaded with a wide range of format options
But did you know that you are not limited to the pre-defined options
Some organisations have specific standards for things such as date formats, these can be catered for using custom formats
https://www.selectdistinct.co.uk/2023/07/20/custom-formats-in-power-bi/
#powerbi #dataviz #customformats
You have heard of the 80:20 rule (Pareto)
Power BI has a TOPN function in DAX
This guide shows you how to start using it
https://www.selectdistinct.co.uk/2023/06/28/topn-in-power-bi/
#powerbi #topn #businessintelligence
In the world of data analysis, having the ability to efficiently rank and prioritize information is crucial. This is where the TOPN function in Power BI comes into play. By utilizing this powerful ranking function, analysts and data professionals can gain valuable insights from their datasets.
The TOPN function, short for "top n," allows users to identify and retrieve the top or bottom records based on a specified criteria. This function is particularly useful when dealing with large datasets that require quick and accurate analysis.
With Power BI's extensive capabilities, the TOPN function can be utilized through its native DAX (Data Analysis Expressions) formula language. By incorporating this formula into your Power BI reports and dashboards, you can effectively sort and filter data to highlight key trends, outliers, or patterns.
The importance of the TOPN function lies in its ability to streamline decision-making processes by presenting relevant information in a concise manner. Whether you are analysing sales figures, customer satisfaction ratings, or any other dataset, being able to quickly identify the top performers or underperformers can greatly impact strategic decision-making.
In this section, we will delve deeper into understanding how the TOPN function works within Power BI and explore real-world use cases where it can be applied effectively. So let's dive in and unlock the full potential of this essential feature in Power BI!
Do you want to learn how to unpivot a table in SQL Server?
Unpivot is a handy operator that converts columns into rows, making your data more normalized and readable.
Check out my latest blog post to see how it works and why you should use it.
https://www.selectdistinct.co.uk/2023/06/12/unpivot-function-in-sql/
#sql #unpivot #datatransformation #sqlserver #blogpost
Chatty Kathy - UNC Bootcamp Final Project Presentation - Final Version - 5.23...John Andrews
SlideShare Description for "Chatty Kathy - UNC Bootcamp Final Project Presentation"
Title: Chatty Kathy: Enhancing Physical Activity Among Older Adults
Description:
Discover how Chatty Kathy, an innovative project developed at the UNC Bootcamp, aims to tackle the challenge of low physical activity among older adults. Our AI-driven solution uses peer interaction to boost and sustain exercise levels, significantly improving health outcomes. This presentation covers our problem statement, the rationale behind Chatty Kathy, synthetic data and persona creation, model performance metrics, a visual demonstration of the project, and potential future developments. Join us for an insightful Q&A session to explore the potential of this groundbreaking project.
Project Team: Jay Requarth, Jana Avery, John Andrews, Dr. Dick Davis II, Nee Buntoum, Nam Yeongjin & Mat Nicholas
As Europe's leading economic powerhouse and the fourth-largest hashtag#economy globally, Germany stands at the forefront of innovation and industrial might. Renowned for its precision engineering and high-tech sectors, Germany's economic structure is heavily supported by a robust service industry, accounting for approximately 68% of its GDP. This economic clout and strategic geopolitical stance position Germany as a focal point in the global cyber threat landscape.
In the face of escalating global tensions, particularly those emanating from geopolitical disputes with nations like hashtag#Russia and hashtag#China, hashtag#Germany has witnessed a significant uptick in targeted cyber operations. Our analysis indicates a marked increase in hashtag#cyberattack sophistication aimed at critical infrastructure and key industrial sectors. These attacks range from ransomware campaigns to hashtag#AdvancedPersistentThreats (hashtag#APTs), threatening national security and business integrity.
🔑 Key findings include:
🔍 Increased frequency and complexity of cyber threats.
🔍 Escalation of state-sponsored and criminally motivated cyber operations.
🔍 Active dark web exchanges of malicious tools and tactics.
Our comprehensive report delves into these challenges, using a blend of open-source and proprietary data collection techniques. By monitoring activity on critical networks and analyzing attack patterns, our team provides a detailed overview of the threats facing German entities.
This report aims to equip stakeholders across public and private sectors with the knowledge to enhance their defensive strategies, reduce exposure to cyber risks, and reinforce Germany's resilience against cyber threats.
StarCompliance is a leading firm specializing in the recovery of stolen cryptocurrency. Our comprehensive services are designed to assist individuals and organizations in navigating the complex process of fraud reporting, investigation, and fund recovery. We combine cutting-edge technology with expert legal support to provide a robust solution for victims of crypto theft.
Our Services Include:
Reporting to Tracking Authorities:
We immediately notify all relevant centralized exchanges (CEX), decentralized exchanges (DEX), and wallet providers about the stolen cryptocurrency. This ensures that the stolen assets are flagged as scam transactions, making it impossible for the thief to use them.
Assistance with Filing Police Reports:
We guide you through the process of filing a valid police report. Our support team provides detailed instructions on which police department to contact and helps you complete the necessary paperwork within the critical 72-hour window.
Launching the Refund Process:
Our team of experienced lawyers can initiate lawsuits on your behalf and represent you in various jurisdictions around the world. They work diligently to recover your stolen funds and ensure that justice is served.
At StarCompliance, we understand the urgency and stress involved in dealing with cryptocurrency theft. Our dedicated team works quickly and efficiently to provide you with the support and expertise needed to recover your assets. Trust us to be your partner in navigating the complexities of the crypto world and safeguarding your investments.
2. CTEs in SQL are a way to simplify code by creating a temporary dataset, giving it a
name, then referencing that dataset later in your query
Also known as the WITH clause
3. Syntax of the CTE in SQL
WITH Merged as
(
SELECT [Product_ID], [Store_ID], [qty_sold] from SalesA
union
SELECT [Product_ID], [Store_ID], [qty_sold] from SalesB
)
SELECT * from Merged
‘WITH’ is the start, followed by the name of
the data set
Then within brackets goes the SQL code for
the dataset
Finally you can call it as you would a
table or subquery
4. Benefits of CTEs
Simplicity
simplify complex queries and improve their readability
Performance
improve query performance by breaking down complex
queries into smaller, more manageable parts
5. Limitations of CTEs
Limited Scope
Can only be utilized within a SELECT, INSERT, UPDATE, or
DELETE statement
Memory Usage
can consume a lot of memory
Performance
can sometimes be slower than other methods, such as
temporary tables
6. Recursive Queries
WITH CTE
AS
(
SELECT cast(GETDATE()AS date) AS [date]
UNION ALL
SELECT DATEADD(dd, 1, [date])
FROM CTE
WHERE DATEADD(dd, 10, [date])
< CAST('2023-12-31' as date)
)
SELECT [date] FROM CTE
We can use a recursive CTE to refer back to itself in a loop
Here we see a list of dates, between today and fixed end date
7. CTEs are used for a variety of reasons, including simplifying complex queries,
improving query performance, and making queries more readable.
They are also useful for breaking down complex queries into smaller, more
manageable parts.
8. For more Tips, Tricks and
Timesavers, visit our website
Business Analytics Blog – Select Distinct
Credit: simon.harrison@selectdistinct.co.uk