2 added 153 characters in body
source | link

I have an Orders table (text customer_id, int total_orders) which contains overview stats of total orders for each customer.

enter image description here

What I am trying to do is generate a query output that will represent a customer as a row for each third order they've made similar to this.

enter image description here

The combined_key is used as the primary/unique key which is simply the customer_key and count combined as I cannot use an auto-number.

I know how I can identify which records I need to be in the query but I don't know how I can split the records as desired.

select *
from stats
where order_count / 3

I've included a fiddle, please note it's in MySQL because T-SQL is not available.

I have an Orders table (text customer_id, int total_orders) which contains overview stats of total orders for each customer.

enter image description here

What I am trying to do is generate a query output that will represent a customer as a row for each third order they've made similar to this.

enter image description here

The combined_key is used as the primary/unique key which is simply the customer_key and count combined as I cannot use an auto-number.

I know how I can identify which records I need to be in the query but I don't know how I can split the records as desired.

select *
from stats
where order_count / 3

I have an Orders table (text customer_id, int total_orders) which contains overview stats of total orders for each customer.

enter image description here

What I am trying to do is generate a query output that will represent a customer as a row for each third order they've made similar to this.

enter image description here

The combined_key is used as the primary/unique key which is simply the customer_key and count combined as I cannot use an auto-number.

I know how I can identify which records I need to be in the query but I don't know how I can split the records as desired.

select *
from stats
where order_count / 3

I've included a fiddle, please note it's in MySQL because T-SQL is not available.

1
source | link

Splitting row into multiple records based on row value

I have an Orders table (text customer_id, int total_orders) which contains overview stats of total orders for each customer.

enter image description here

What I am trying to do is generate a query output that will represent a customer as a row for each third order they've made similar to this.

enter image description here

The combined_key is used as the primary/unique key which is simply the customer_key and count combined as I cannot use an auto-number.

I know how I can identify which records I need to be in the query but I don't know how I can split the records as desired.

select *
from stats
where order_count / 3