đề pesu23
đề pesu23
đề pesu23
LastName VARCHAR(50),
FirstName VARCHAR(50),
Phone VARCHAR(50),
Address VARCHAR(100),
City VARCHAR(50),
Country VARCHAR(50)
OrderDate DATE,
RequiredDate DATE,
ShippedDate DATE,
Status VARCHAR(50),
Comment VARCHAR(255),
Name VARCHAR(100),
Scale VARCHAR(50),
Vendor VARCHAR(100),
Description TEXT,
Inventory INT
)
CREATE TABLE OrderDetail (
OrderID INT ,
ProductCode VARCHAR(50),
Qty INT,
);
--Q2
-- Q3
--3.1
FROM Customer
--3.2
FROM OrderDetail;
-- 3.3
FROM OrderDetail
WHERE MONTH(OrderDate) = 6
GROUP BY ProductCode
HAVING SUM(Quantity) >= ALL (
SELECT SUM(Quantity)
FROM OrderDetail
WHERE MONTH(OrderDate) = 6
GROUP BY ProductCode
OR (
FROM OrderDetail
WHERE MONTH(OrderDate) = 6
GROUP BY ProductCode
) = 1;
-- 3.4
FROM Order1
Nam
general scripts
Write an SQL query to create table Account Types with the following properties:
(Cannot be null)
);
C.
Write an SQL query to create table Accounts with the following properties:
Balance - decimal data type with up to 15 digits including 2 after the decimal point
AccountTypeId INT,
ClientId INT,
);
write an sql query to find the first name and the last name of each Client
FROM Clients;
e. Create a table - Logs (Logld, Accountld, OldBalance, NewBalance). Add a trigger to the
Accounts table that inserts a new record into the Logs table every time the balance on an
account changes.
AccountId INT,
);
DELIMITER //
BEGIN
END IF;
END //
DELIMITER ;
Write an SQL query to find first and last names of all employees whose last name
"n" or "t".
SELECT FirstName, LastName
FROM Employees
To find the average salary for each department, you can use the following SQL query:
FROM Employees
GROUP BY DepartmentID;
Find all the employees whose salary is equal to the maximum salary of their department.
FROM Employees e
INNER JOIN (
FROM Employees
GROUP BY DepartmentID
write an SQL query to find first and last name of 10 best paid employees, ordered descending by their
salary
FROM employees
ORDER BY salary DESC
LIMIT 10;
returns nvarchar(50)
as
begin