N
N
Nikita Rubinkovskiy2019-06-24 17:03:15
Database design
Nikita Rubinkovskiy, 2019-06-24 17:03:15

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.5d10d7e7021f7171292977.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Tsvetkov, 2019-06-24
@tsklab

It is necessary in the database
CREATE QUEUE .
It is necessary to put 1 or 0 in the promo cell of the sales table
Bet 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 )

D
d-stream, 2019-06-25
@d-stream

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 oninner join promotions onwhere sales date_id between promolist.start and promolist.end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question