challengeAccepted
challengeAccepted

Reputation: 7610

Simple sql query issue using 2 tables

as i learner, i would like to learn how will be a sql statement for this condition.

I have 2 tables: Statistics and Promotions. There is no column called stats in any of the tables. Statistics has LocationID and ClickDate. Promotion has PromotionID, LocationID and CreateDate

i need Select PromotionID, stats from Promotions and Statistics ....

stats for each promotionID should be calculated as Number of columns in Statistics that has clickdate > createDate(promotion) for locationID =111 and PromotionID = 988;

Thanks in advance.

Upvotes: 0

Views: 58

Answers (1)

Leslie
Leslie

Reputation: 3644

here's a start:

SELECT PromotionID, S.*
FROM Statistics S
INNER JOIN Promotions P on S.LocationID = P.LocationID
WHERE S.ClickDate>P.CreateDate and S.LocationID = 111 and P.PromotionID = 988

Upvotes: 1

Related Questions