Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. CREATE TABLE Users(
  2. uid int PRIMARY KEY,
  3. name text,
  4. phone text
  5. );
  6. CREATE TABLE Messages(
  7. recipient int REFERENCES Users(uid),
  8. sender int REFERENCES Users(uid),
  9. time timestamp NOT NULL,
  10. message text NOT NULL,
  11. PRIMARY KEY (recipient, sender, time)
  12. );
  13.  
  14. SELECT COUNT(distinct U2.uid)
  15. FROM Users U2,Messages M
  16. WHERE M.sender=U2.uid AND U2.name<>'Freddy' AND M.recipient=(SELECT U.uid FROM Users U,Messages M
  17. WHERE M.recipient=U.uid AND M.sender=(SELECT uid FROM Users where name='Freddy'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement