Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

calculation - PostgresSQL calculate daily cost

I want to work out daily cost for each advert based on number of days it's running. Also to show days in the period from the start to end. in dataset I have 5 columns for a media campaign. Col A Id eg A001 Col B Advert Col C Cost eg 300 Col D startdate eg 01-01-2021 Col E enddate eg 30-01-2010 For this record enddate is 30 days after startdate What I want

  1. Create 30 rows from that 1 row of data
  2. Each row to repeat details for Col A to Col E
  3. Col F to show all the days from start to end row 1 is startdate row 2 is startdate plus 1 day row 3 is startdate plus 2 days and so on until row 30 is enddate
  4. Then col F have 30 rows based on cost divided by number of rows which is 30 in this case row 1 is 10 which is 300 divided by 30 row 2 is 10 and so on to row 30 which is 10
question from:https://stackoverflow.com/questions/66060121/postgressql-calculate-daily-cost

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...