ERD is a common way to view data in a database.
It helps you visualize the data you are analyzing including:
- the names of the tables.
- the columns in each table
- the way the tables work together
SQL (Structured Query Language)
- easy to understand
- access data directly
- easy to audit and replicate
- multiple tables at once
- allows you to analyze more complex questions than dashboard tools like Google Analytics
Why Do Business Choose SQL?
- Data integrity is ensured.
- Data can be accessed quickly.
- Data is easily shared.
Types of Statements
- Create table: creates a new table in a database
- Drop table: removes a table in a database
- Select - query: allows you to read data and display it.
Select & From
- Select: tell the query what columns you want back.
- From: what table you are querying from.
select *
from demo.order
Queries
LIMIT
- seeing only a few lines of data
- in MySQL, used as
select top 10 *
from orders;
ORDER BY
- order out table by any row
- default: ascending order / put 'desc' at the end for descending order
select *
from web_events
order by occurred_at desc
- create an order within the order
select occurred_at, total_amt_usd
from orders
order by total_amt_usd desc, occurred_at desc
limit 5
WHERE
subset out tables based on conditions that must be met.
when finding non-numeric values, put a single quotation mark
- > (greater than)
- < (less than)
- >= (greater than or equal to)
- <= (less than or equal to)
- = (equal to)
- != (not equal to)
select *
from orders
where gloss_amt_usd > 1000
limit 5
select name, website, primary_poc
from accounts
where name = 'Exxon Mobil'
DERIVED COLUMN
common operators include:
- * (Multiplication)
- + (Addition)
- - (Subtraction)
- / (Division)
select id, account_id, standard_amt_usd/standard_qty as unit_price
from orders
limit 10
LIKE
This allows you to perform operations similar to using WHERE and =,
but for cases when you might not know exactly what you are looking for.
- Wildcards(%)
- Case-sensitive
select *
from orders
where account LIKE '%google%'
select name
from accounts
where name like 'C%'
IN
This allows you to perform operations similar to using WHERE and =,
but for more than one condition.
select name, primary_poc,sales_rep_id
from accounts
where name in ('Walmart', 'Target', 'Nordstrom')
NOT
This is used with IN and LIKE to select all of the rows NOT LIKE or NOT IN a certain condition.
select name, primary_poc,sales_rep_id
from accounts
where name NOT in ('Walmart', 'Target', 'Nordstrom')
select *
from web_events
where channel NOT in ('organic', 'adwords' )
select name
from accounts
where name not like '%s'
AND & BETWEEN
These allow you to combine operations where all combined conditions must be true.
select *
from orders
where standard_qty > 1000
and poster_qty = 0
and gloss_qty = 0
select *
from accounts
where name NOT LIKE 'C%'
AND NAME NOT LIKE '%s'
select *
from web_events
where channel in ('organic', 'adwords')
and occurred_at between '2016-01-01' and '2017-01-01'
order by occurred_at desc
OR
This allows you to combine operations where at least one of the combined conditions must be true.
select id
from orders
where gloss_qty > 4000 or poster_qty > 4000
select *
from orders
where standard_qty = 0 or (gloss_qty > 1000 or poster_qty > 1000)
select *
from accounts
where *name like 'C%' OR NAME LIKE 'W%' )
and (primary_poc LIKE '%ana%' or primary_poc LIKE '%Ana%')
and or primary_poc NOT LIKE '%eana%'
Summary
Statement | How to Use It | Other Details |
---|---|---|
SELECT | SELECT Col1, Col2, ... | Provide the columns you want |
FROM | FROM Table | Provide the table where the columns exist |
LIMIT | LIMIT 10 | Limits based number of rows returned |
ORDER BY | ORDER BY Col | Orders table based on the column. Used with DESC. |
WHERE | WHERE Col > 5 | A conditional statement to filter your results |
LIKE | WHERE Col LIKE '%me%' | Only pulls rows where column has 'me' within the text |
IN | WHERE Col IN ('Y', 'N') | A filter for only rows with column of 'Y' or 'N' |
NOT | WHERE Col NOT IN ('Y', 'N') | NOT is frequently used with LIKE and IN |
AND | WHERE Col1 > 5 AND Col2 < 3 | Filter rows where two or more conditions must be true |
OR | WHERE Col1 > 5 OR Col2 < 3 | Filter rows where at least one condition must be true |
BETWEEN | WHERE Col BETWEEN 3 AND 5 | Often easier syntax than using an AND |
Udemy free course for beginners with absolutely no experience is database. The course will make you familiar with SQL Syntax and introduce you to the concept of databases.
ReplyDeletehttps://knowit-now.com/udemy-databases-and-sql-introduction/
nicePPC Services
ReplyDeletepay per click services
very good blog and Useful Information. plz keep sharing.
ReplyDeleteIf you are looking for website Designing .
Best website designer in Delhi
SEO packages in Delhi
Best website designer in Delhi
Best website designer in Delhi
Top Website Designing Company in Delhi
Best website developer in Delhi
Directories are excellent places to make some backlinks to help your link building. You can earn good page rank by submitting your site on directory. Google, Yahoo, Bing consider the presence
ReplyDeleteof your site on internet. I choose some directories with good page rank to grow up your page rank.
50+ Free Directory Submission Sites to Get Crazy Traffic
Codeaxia Digital Solutions is a digital agency based out of Delhi/NCR. We provide valuable & economical digital solutions for the customers in areas such as website designing, development & maintenance, graphic designing, digital marketing and mobile applications development. Codeaxia provides best solutions for -
ReplyDeleteWeb Designing
Web Development
Ecommerce Web Development
Digital Marketing
Codeforstartups is best website development and Digital marketing service company, its provide world wide service like SEO, Website design and development at affordable price, prax design is a UI UX Design site for create user interface and attractive design.
ReplyDelete1. Website design
2. Mobile app design
3. Digital Marketing
4. Graphics design
5. UI UX Design
Nice article. I liked very much. All the informations given by you are really helpful for my research. keep on posting your views.
ReplyDeleteIf you require new company registration bangalore
and one person company registration in bangalore
plz click on it .
Film108 is one of the best movie promotion and marketing agency in Mumbai, always trying to adapt to innovative approaches for each brand and mark a difference in the digital world.
ReplyDeletevery good blog and Useful Information. plz keep sharing.
ReplyDeleteIf you are looking for Education Courses.
Career after commerce graduation
MBA Pharma
Top 10 LLB colleges in india
GATE 2022
IIT Jam 2022
XAT 2022