Skip to content

Commit

Permalink
Added report "first bought date"
Browse files Browse the repository at this point in the history
  • Loading branch information
morrisonbrett committed Mar 11, 2024
1 parent 3a282c6 commit bfdea5e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions scripts/Reports.sql
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,21 @@ WHERE SellerUserId IS NOT NULL
WHERE bb2.SessionId = bb.SessionId
AND bb2.SellerUserId = bb.BuyerUserId
)
AND NOT EXISTS (
SELECT UserId from Regulars WHERE UserId = bb.BuyerUserId
)
)
ORDER BY SessionDate DESC

/* Subs first bought by date */
SELECT Name, SessionDate, BuySellsSessionId, BuyerUserId FROM BuySellsByBuyer
WHERE SellerUserId IS NOT NULL
AND SessionDate = (
SELECT MIN(SessionDate) FROM BuySellsByBuyer bb
WHERE bb.BuyerUserId = BuySellsByBuyer.BuyerUserId
AND bb.SellerUserId IS NOT NULL
AND NOT EXISTS (
SELECT 1 FROM BuySellsByBuyer bb2
WHERE bb2.SessionId = bb.SessionId
AND bb2.SellerUserId = bb.BuyerUserId
)
)
ORDER BY SessionDate DESC

Expand Down

0 comments on commit bfdea5e

Please sign in to comment.