Answer the question
In order to leave comments, you need to log in
How to write a SQL script?
It is necessary to put 1 or 0 in the promo cell of the sales table, depending on whether the product (good_id) was sold from the store (store_id) on the specified date (date_id) for a promotion (that is, whether the date is within the start-end interval) .
The promoplan, promolist, and promotions tables contain this information, but instead of good_id and store_id, they contain other names (good_cod and store_cod), the dictionary for which is given in the goods and stores tables, respectively.
The promoplan and promolist tables complement each other in the sense that the promo date (name) from the promoplan table is specified in the promolist table.
Answer the question
In order to leave comments, you need to log in
It is necessary in the databaseCREATE QUEUE .
It is necessary to put 1 or 0 in the promo cell of the sales tableBet during the sale, because at this moment the price is calculated. All preliminary calculations can be done either in a stored procedure ( CREATE PROCEDURE ) or in a trigger before adding ( CREATE TRIGGER INSTEAD OF INSERT )
I got confused in the verbal description, but here's the canvas offhand:
update sales
set promo=1
from sales
inner join goods on ….
inner join stores on ….
inner join promplan on …
inner join promotions on …
where sales date_id between promolist.start and promolist.end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question