-2
can help me with this consultation?
CREATE TABLE Region
(
idRegion INT PRIMARY KEY IDENTITY(1,1)
,cdRegion VARCHAR(50)
)
CREATE TABLE Store(
idStore INT PRIMARY KEY IDENTITY(1,1)
,cdStore VARCHAR(50)
,dsStore VARCHAR(200)
)
CREATE TABLE StorexRegion
(
idStore INT FOREIGN KEY REFERENCES Store(idStore)
,idRegion INT FOREIGN KEY REFERENCES Region(idRegion)
)
CREATE TABLE Sales(
idSales INT PRIMARY KEY IDENTITY(1,1)
,idStore INT FOREIGN KEY REFERENCES Store(idStore)
,idRegion INT FOREIGN KEY REFERENCES Region(idRegion)
,vlTotal FLOAT
)
Using the above tables, create a query that links a store to the corresponding region(s)
I tried this consultation, I don’t know if it’s correct:
SELECT
*
FROM
STORE S
INNER JOIN REGION R ON S.IDSTORE = R.IDREGION
Create a query that devotes the total amount of sales from one store per Region
SELECT
SUM(S.VLTOTAL)
FROM
SALES S
INNER JOIN STORE ST ON S.IDSALES = ST.IDSORTE
INNER JOIN REGION R ON = S.IDSALES = R.IDREGION
GROUP BY R.IDREGION
help us can, show us what you’ve done, put the
select
who has tried– Ricardo Pontual
Tentei essas duas:
1-
SELECT * FROM STORE S INNER JOIN REGION R
ON S.IDSTORE = R.IDREGION

2- 
SELECT SUM(S.VLTOTAL) * FROM SALES S INNER JOIN STORE ST
ON S.IDSALES = ST.IDSORTE
INNER JOIN REGION R
ON = S.IDSALES = R.IDREGION
GROUP BY R.IDREGION
– Lucas Lira
Put an example with registration in http://sqlfiddle.com/ this way we can help you more easily
– Tiedt Tech
edit the question and place the query there to get a better view
– Ricardo Pontual
edited the question, apologies for the way I did here..
– Lucas Lira
@Lucaslira edited the question, but we still need an example of data to help you
– Tiedt Tech