Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Create Names table
- CREATE TABLE names
- (
- id INT IDENTITY PRIMARY KEY,
- name VARCHAR(128) NOT NULL,
- timestamp BIGINT NOT NULL
- )
- -- Insert data in the DB
- INSERT INTO [dbo].[names](name,timestamp) Values ('Pesho', 123456);
- -- Get count of entries
- SELECT count(*) FROM [dbo].[names] as n
- WHERE n.name = 'Pesho';
- -- Select first entry
- SELECT n.name, MIN(n.timestamp) FROM [dbo].[names] AS n
- GROUP BY n.name
- HAVING n.name = 'Pesho';
Add Comment
Please, Sign In to add comment