Sms SQL
Sms SQL
Create sequence:
CREATE SEQUENCE DEPARTMENT_S START WITH 1 INCREMENT BY 1;
Create Trigger:
CREATE OR REPLACE TRIGGER "DEPARTMENT_SEQ"
before insert on "DEPARTMENT"
for each row
begin
if :NEW."ID" IS NULL THEN
SELECT "DEPRTMENT_S".nextval into :NEW."ID" from sys.dual;
end if;
end;
/
select "ID",
"NAME",
"PHONENUMBER"
from "#OWNER#"."MECHANIC"
Send sms:
https://dba.stackexchange.com/questions/75473/insert-missing-dates-from-a-query
https://stackoverflow.com/questions/10395459/comparing-results-with-todays-date
"SQL1"."ISEQ$$_73540".nextval
NEXT VALUE FOR PRIMARY KEY
============================================================
SELECT last_name, commission_pct,
(CASE commission_pct
WHEN 0.1 THEN 'Low'
WHEN 0.15 THEN 'Average'
WHEN 0.2 THEN 'High'
ELSE 'N/A' END ) Commission
FROM
employees
ORDER BY
last_name;
==================================================================
SELECT last_name, job_id, salary,
(CASE
WHEN job_id LIKE 'SA_MAN' AND salary < 12000 THEN '10%' or %% added in the
end.
WHEN job_id LIKE 'SA_MAN' AND salary >= 12000 THEN '15%'
WHEN job_id LIKE 'IT_PROG' AND salary < 9000 THEN '8%'
WHEN job_id LIKE 'IT_PROG' AND salary >= 9000 THEN '12%'
ELSE 'NOT APPLICABLE'
END ) Raise
FROM employees;
=============================================================================
* CASE 1: Books with total sales greater than $100,000, display "Best Seller"
* CASE 2: Books with total sales between $10,000 and $99,999 display "Average
Seller"
* CASE 3: Books with sales less than $10,000 display "Poor Seller"
ANSWER:
select
(case
when sum(quantity)*book_retail_price > 100000 then 'Best Seller'
when sum(quantity)*book_retail_price < 10000 then 'Poor Seller'
else 'Average Seller'
end ) sales,
store_name,
book_title,
sum(quantity)*book_retail_price total_sales
from
store,
sales,
book
where
store.store_key = sales.store_key
and
sales.book_key = book.book_key
group by
store_name,
book_title,
book_retail_price
order by
total_sales desc
;
================================================================