Sample table: customer customer_id | cust_name | city | grade | salesman_id ---+---+---+---+--- 3002 | Nick Rimando | New York | 100 | 5001 3007 | Brad Davis | New York | 200 | 5001 3005 | Graham Zusi | California | 200 | 5002 3008 | Julian Green | London | 300 |...
let’s see how many rows the table contains. To do this, we’ll execute the SELECT query with the COUNT(*) function that returns the number of all rows in the table.
Sample table: company_mast COM_ID COM_NAME --- --- 11 Samsung 12 iBall 13 Epsion 14 Zebronics 15 Asus 16 Frontech Click me to see the solution 34. Find Employees with Last Name Gabriel or Dosio From the following tables write a SQL query to find employees whose last name is Gabriel...
Adata modelis an organized design of how the data of entities in a database are related to each other. Some examples of common data model architectures areData VaultandData Mesh. Adbt modelcan be thought of as a blueprint of a table or view that represents entities in a database. It i...
SQL Server table hints – WITH (NOLOCK) best practices SQL WHILE loop with simple examples The Table Variable in SQL Server Overview of SQL RANK functions SELECT INTO TEMP TABLE statement in SQL Server SQL Server functions for converting a String to a Date How to identify and resolve...
Today is the day for SQL practice #1. In this series, so far, we’ve covered most important SQL commands (CREATE DATABASE & CREATE TABLE, INSERT, SELECT) and some concepts (primary key, foreign key) and theory (stored procedures, user-defined functions, views). Now it’s time to discu...
It's a good practice to createnamed constraintsso that it is easier to alter and drop constraints. Here's an example to create a namedCHECKconstraint: -- create a named constraint named amountCK-- the constraint makes sure that amount is greater than 0CREATETABLEOrders ( ...
Hint: It’s always better to manually type the code found in these samples. It creates “finger memory” and helps you get more practice in typing the code when you need to later in the real world. CREATE TABLE empDepartment( DeptID INT PRIMARY KEY NOT NULL, ...
SELECT INTO Temp Table Examples Example 1 – Using SELECT INTO Temp Table to Categorize Products The script below creates a temporary table and then shares it to get 2 different query results. The temporary table stores individual products and their categories. Then, the next query gets the sale...
Table comparison cheat sheet Here's a summary of the different methods in this post. Other ways exist, for example thedbms_comparison package. Setup scripts Create these tables to run the examples above. To run it interactively in the browser,get the scripts on Live SQL. ...