0% found this document useful (0 votes)
6 views

SQL - AND OR - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SQL - AND OR - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3/2/2016 SQL ­ AND OR | 1Keydata

SQL AND OR

SQL Data Warehousing CSS PHP HTML Database Normalization

SQL Tutorial Training on Cloud Computing Enroll N


Basic SQL Commands
SQL SELECT
SQL DISTINCT
SQL WHERE SQL > SQL Commands > And Or
SQL AND OR
In the previous section, we have seen that the WHERE keyword can be used to conditionally select data from a table. This
SQL IN
simple condition (like the one presented in the previous section), or it can be a compound condition. Compound condition
SQL BETWEEN
multiple simple conditions connected by AND or OR. There is no limit to the number of simple conditions that can be pres
SQL Wildcard statement.
SQL LIKE
SQL ORDER BY The syntax for a compound condition is as follows:
SQL GROUP BY
SQL HAVING SELECT "column_name"
SQL ALIAS FROM "table_name"
WHERE "simple condition"
SQL AS
{ [AND|OR] "simple condition"}+;
SQL SELECT UNIQUE
SQL JOIN
The { }+ means that the expression inside the bracket will occur one or more times. [AND|OR] means that either AND
SQL INNER JOIN
addition, we may use the parenthesis sign ( ) to indicate the order of the condition.
SQL OUTER JOIN
SQL LEFT OUTER JOIN For example, we may wish to select all stores with sales greater than $1,000 or all stores with sales less than $500 but gr
SQL CROSS JOIN Table Store_Information,
SQL INSERT INTO
SQL INSERT INTO SELECT Table Store_Information
SQL UPDATE
Store_Name Sales Txn_Date
SQL DELETE FROM
Los Angeles 1500 Jan-05-1999
Advanced SQL
San Diego 250 Jan-07-1999
SQL UNION
San Francisco 300 Jan-08-1999
SQL UNION ALL
Boston 700 Jan-08-1999
SQL Inline View
SQL INTERSECT
we key in,
SQL MINUS
SQL LIMIT
SELECT Store_Name
SQL TOP FROM Store_Information
SQL Subquery WHERE Sales > 1000
SQL EXISTS OR (Sales < 500 AND Sales > 275);
SQL CASE
SQL DECODE Result:
SQL AUTO INCREMENT
SQL IDENTITY Store_Name
SEQUENCE & NEXTVAL Los Angeles
San Francisco
SQL Functions
SQL Average
SQL COUNT
SQL MAX Google Drive For Work
SQL MIN Unlimited Storage For Your Docs, Slides And Spreadsheets ­ $10/Month
SQL SUM
SQL ROUND

String Functions Exercises


SQL CAST
SQL CONVERT For these exercises, assume we have a table called Users with the following data:
SQL CONCATENATE
SQL SUBSTRING Table Users
SQL INSTR
First_Name Last_Name Birth_Date Gender Join_Date
SQL TRIM
Sophie Lee Jan-05-1960 F Apr-05-2015
http://www.1keydata.com/sql/sqlandor.html 1/2
3/2/2016 SQL ­ AND OR | 1Keydata
Sophie Lee Jan-05-1960 F Apr-05-2015
SQL LENGTH
SQL REPLACE Richard Brown Jan-07-1975 M Apr-05-2015
SQL TO_DATE Jamal Santo Oct-08-1983 M Apr-09-2015
Casey Healy Sep-20-1969 M Apr-09-2015
Date Functions
Jill Wilkes Nov-20-1979 F Apr-15-2015

1. Which of the following SQL statement is valid? (There can be more than one answer)
a) SELECT First_Name AND Last_Name FROM Users;
b) SELECT First_Name, Last_Name FROM Users WHERE Join_Date > 'Apr-01-2015' AND Birth_Date < 'Jan-01-1980';
c) SELECT First_Name OR User_Name FROM Users;
d) SELECT * FROM Users WHERE Last_Name = 'Brown' AND Gender = 'F';

2. How many records will be returned by the following query?


SELECT * FROM User WHERE Gender = 'M' AND Join_Date = 'Apr-09-2015';

3. How many records will be returned by the following query?


SELECT * FROM User WHERE Gender = 'M' OR Join_Date = 'Apr-05-2015';

Show Answers

Next: SQL IN

New: handheld scope


Simply better ­ in the lab and in the field: new R&S®Scope Rider.

Copyright © 2016 1keydata.com All Rights Reserved Privacy Policy About Contact

http://www.1keydata.com/sql/sqlandor.html 2/2

You might also like