Avatar of rajvja
rajvja
Flag for United Kingdom of Great Britain and Northern Ireland asked on

Complex sql query

Hi Experts,

 I am struggling to generate the resultset.

I have a table which hold StorePointsByCustomer

Please see the attached spreadsheet what I need to generate.

 I need to get the points spent split by earnings.
PointsQuery.xlsx
Microsoft SQL Server 2008

Avatar of undefined
Last Comment
harfang

8/22/2022 - Mon
santhimurthyd

Hi

Could you share more about your requiremnt
In the Result table you have all teh TransactionId's as 4, whre in the source table it's 1,2,..6.

Is it's the requirment and also on which condition the Earnign Points are getting splitted into the record which si not having and aslo teh no of records in Source is 6, where as in the result it's 5.
rajvja

ASKER
Hi santhimurthyd,

  Thanks for the reply.

I need to generate the result for SpentPoints. As I said, the points might have earned on different transactions. So, I want all the earn dates corresponding toeach spent transaction.

Hope you understand.
SOLUTION
michalsmiechowski

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
harfang

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
harfang

PS: I realise that you will have to port it to SQL Server, but once I got started thinking about a possible algorithm, I had to go through with it. In the end, it's quite similar to what michalsmiechowski just suggested.

(°v°)
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Zberteoc

If you can explain in words what you want will help. From that file I cannot understand what exactly it is that you want to achieve.
Zberteoc

Comment removed. Posted in the wrong question.
rajvja

ASKER
Hi all,

   My requirement is to get spent points based on the earned date.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
harfang

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
rajvja

ASKER
Thanks guys but sorry that the solutions not solved my problem
harfang

Sorry I couldn't help more. Success with your project! — (°v°)