public inbox for [email protected]  
help / color / mirror / Atom feed
Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range
4+ messages / 2 participants
[nested] [flat]

* Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range
@ 2023-02-25 20:35  nikhil raj <[email protected]>
  0 siblings, 2 replies; 4+ messages in thread

From: nikhil raj @ 2023-02-25 20:35 UTC (permalink / raw)
  To: pgsql-sql

Hi All,

Need help in rotation of data in *Postgres*.

There is a table called crew_details

[image: enter image description here] <https://i.stack.imgur.com/cTarQ.png;

There is a requirement to rotate the crew members for in weekly or on the
every 7th day and continue for rest 6days the same order of for the given
date range un till it reach end date . and the expected output should be
like this below

[image: >] <https://i.stack.imgur.com/hjasI.png;

Please can any one help me in in the rotation in *postgres SQL*


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range.
@ 2023-02-25 21:04  nikhil raj <[email protected]>
  parent: nikhil raj <[email protected]>
  1 sibling, 0 replies; 4+ messages in thread

From: nikhil raj @ 2023-02-25 21:04 UTC (permalink / raw)
  To: pgsql-sql

Hi All,

Need help in rotation of data in *Postgres*.

There is a table called crew_details

[image: enter image description here] <https://i.stack.imgur.com/cTarQ.png;

There is a requirement to rotate the crew members for in weekly or on the
every 7th day and continue for rest 6days the same order of for the given
date range un till it reach end date . and the expected output should be
like this below

[image: >] <https://i.stack.imgur.com/hjasI.png;

Please can any one help me in in the rotation in *postgres SQL*


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range
@ 2023-02-25 21:56  Steve Midgley <[email protected]>
  parent: nikhil raj <[email protected]>
  1 sibling, 1 reply; 4+ messages in thread

From: Steve Midgley @ 2023-02-25 21:56 UTC (permalink / raw)
  To: nikhil raj <[email protected]>; +Cc: pgsql-sql

On Sat, Feb 25, 2023 at 12:37 PM nikhil raj <[email protected]> wrote:

>
> Hi All,
>
> Need help in rotation of data in *Postgres*.
>
> There is a table called crew_details
>
> [image: enter image description here]
> <https://i.stack.imgur.com/cTarQ.png;
>
> There is a requirement to rotate the crew members for in weekly or on the
> every 7th day and continue for rest 6days the same order of for the given
> date range un till it reach end date . and the expected output should be
> like this below
>
> [image: >] <https://i.stack.imgur.com/hjasI.png;
>
> Please can any one help me in in the rotation in *postgres SQL*
>

Thanks for posting the table and output. I'm not totally clear on the
business requirements here but it seems like you have a crew rotation
sequence that is, in this case modulus 5?

I'm not sure I've got the SQL skills to easily make this in a single query
(but surely others here can). But just to clarify the business rules for
such a SQL wizard, I would think the solution involves some kind of hidden
variable (new column, aggregation, built in function?) where the number 1
team member's crew position number is incremented by 1 mod 5 for each new
shift date. Whenever that tracking counter becomes 1 again, convert their
actual shift order number to 5, and subtract 1 from every other crew
members' crew position number. Does that sound like the correct business
rule for the process you're trying to create?

Steve


^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range
@ 2023-02-27 19:45  nikhil raj <[email protected]>
  parent: Steve Midgley <[email protected]>
  0 siblings, 0 replies; 4+ messages in thread

From: nikhil raj @ 2023-02-27 19:45 UTC (permalink / raw)
  To: Steve Midgley <[email protected]>; +Cc: pgsql-sql

Hi Steve,

Yes, that is correct.

On Sun, Feb 26, 2023 at 3:26 AM Steve Midgley <[email protected]> wrote:

>
>
> On Sat, Feb 25, 2023 at 12:37 PM nikhil raj <[email protected]>
> wrote:
>
>>
>> Hi All,
>>
>> Need help in rotation of data in *Postgres*.
>>
>> There is a table called crew_details
>>
>> [image: enter image description here]
>> <https://i.stack.imgur.com/cTarQ.png;
>>
>> There is a requirement to rotate the crew members for in weekly or on the
>> every 7th day and continue for rest 6days the same order of for the given
>> date range un till it reach end date . and the expected output should be
>> like this below
>>
>> [image: >] <https://i.stack.imgur.com/hjasI.png;
>>
>> Please can any one help me in in the rotation in *postgres SQL*
>>
>
> Thanks for posting the table and output. I'm not totally clear on the
> business requirements here but it seems like you have a crew rotation
> sequence that is, in this case modulus 5?
>
> I'm not sure I've got the SQL skills to easily make this in a single query
> (but surely others here can). But just to clarify the business rules for
> such a SQL wizard, I would think the solution involves some kind of hidden
> variable (new column, aggregation, built in function?) where the number 1
> team member's crew position number is incremented by 1 mod 5 for each new
> shift date. Whenever that tracking counter becomes 1 again, convert their
> actual shift order number to 5, and subtract 1 from every other crew
> members' crew position number. Does that sound like the correct business
> rule for the process you're trying to create?
>
> Steve
>


^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2023-02-27 19:45 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-02-25 20:35 Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range nikhil raj <[email protected]>
2023-02-25 21:04 ` Take the data from table and rotate the member on every 7th day or starting day of the week and continue for whole week continue till the date range. nikhil raj <[email protected]>
2023-02-25 21:56 ` Steve Midgley <[email protected]>
2023-02-27 19:45   ` nikhil raj <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox