• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: Ranking table Rows based on shift timing

Resolved: Ranking table Rows based on shift timing

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

i have a table called inputtable with columns equipment_id(int),telemetry_time(timestamp),i want to assign a row_number to the row from 8 am to 8am shift everyday. the below is the sample data link,
INPUT TABLE
equipment_id telemetry_time
2 2022-06-16 04:00:00
2 2022-06-16 04:30:00
2 2022-06-16 06:00:00
2 2022-06-16 06:30:00
2 2022-06-16 08:00:00
2 2022-06-16 08:30:00
2 2022-06-16 20:00:00
2 2022-06-16 23:30:00
2 2022-06-17 02:30:00
2 2022-06-17 03:00:00
2 2022-06-17 10:30:00

REQUIRED OUTPUT
equipment_id telemetry_time Batch
2 2022-06-16 04:00:00 1
2 2022-06-16 04:30:00 2
2 2022-06-16 06:00:00 3
2 2022-06-16 06:30:00 4
2 2022-06-16 08:00:00 1
2 2022-06-16 08:30:00 2
2 2022-06-16 20:00:00 3
2 2022-06-16 23:30:00 4
2 2022-06-17 02:30:00 5
2 2022-06-17 03:00:00 6
2 2022-06-17 10:30:00 1

i have added desired output in the below link with table name desiredtable https://www.db-fiddle.com/f/vhZbgTG8TcJ7SwqanoWEUL/4 please help me im new to SQL,

Answer:

Shift your times back by eight hours to get the right date:
db<>fiddle here

If you have better answer, please add a comment about this, thank you!

database postgresql sql
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: navigate and redirect not redirecting to path in react router

24/03/2023

Resolved: Time Complexity: Find the number of people who know a secret leetcode 2327

24/03/2023

Resolved: Best way to create 3d matrix of variables in PULP

24/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.