Link to home
Create AccountLog in
Avatar of rajvja
rajvjaFlag 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
Avatar of santhimurthyd
santhimurthyd
Flag of United States of America image

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.
Avatar of 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
Avatar of michalsmiechowski
michalsmiechowski

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
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°)
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.
Comment removed. Posted in the wrong question.
Avatar of rajvja

ASKER

Hi all,

   My requirement is to get spent points based on the earned date.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of rajvja

ASKER

Thanks guys but sorry that the solutions not solved my problem
Sorry I couldn't help more. Success with your project! — (°v°)