Skip to content
Advertisement

Tag: distinct

SQL query to fetch distinct values from same table

Let’s say I have this table: employeetable: empid joindate location HRupdatedate Changes 1 2002-01-05 Delhi 2021-03-01 New 2 2009-09-09 Mumbai 2021-03-05 New 1 2010-06-27 Hyderabad 2021-03-03 Transfer 2 2015-11-02 Delhi 2021-03-06 Transfer 3 2020-01-01 Mumbai 2021-03-06 New 4 2007-07-30 Delhi 2021-03-04 New I want to get data from this table where empid in (1,2,4). That will return: empid joindate location

Select Last Rows with Distinct Field

I have a table with the following schema: In this table only the id field is unique. I’m concerned with getting the rows containing the last X distinct itemid, ordered by date. For example, in the sample above, if I’d like to get the last 3 distinct itemid, I’d be getting the first 4 rows, since in the first 4

Finding daily registered users

I have a table which includes the information of player_id, first_timestamp, last_timestamp, and date, etc. So I have initially 10 payers on 2020-07-08, and then 18 players on 2020-07-09, some of the players from previous day might appear on 2020-07-09 again. And I’m trying to find the new players registered on 2020-07-09 that did not appear on 2020-07-08, but I

Advertisement