on 2015 Mar 02 4:00 AM
Hi all,
I have a issue like, I have a Material number and Number of days.
I just want to subtract Min value from Max value and want to store the resultant in another column.
MATERIAL | DAYS |
19395 | 100 |
19395 | 50 |
19395 | 67 |
19395 | 800 |
19395 | 760 |
19395 | 450 |
19395 | 240 |
19395 | 345 |
Anyone can help me out.
Thanks,
GnR
Request clarification before answering.
Goodness...
This is a pretty loose requirement, not to say: are you sure you know what you want to do?
And why you would want to do it?
Ok, first of all: please post the SQL code to create your example instead of the data table.
There's nothing we can really do with your data. Give us the SQL code to create the table and the data and we have something to work with.
Being a nice guy today, I did that for you this time:
create column table mat_days ( material integer, days integer);
insert into mat_days values (19395, 100);
insert into mat_days values (19395, 50);
insert into mat_days values (19395, 67);
insert into mat_days values (19395, 800);
insert into mat_days values (19395, 760);
insert into mat_days values (19395, 450);
insert into mat_days values (19395, 240);
insert into mat_days values (19395, 345);
Now to your request.
You talked about the difference of minimum and maximum days. I assume you meant "per material".
This is then really simple basic SQL 101 and would look like this:
select material, max(days) max_days, min(days) min_days, max(days) - min(days) diff_min_max
from mat_days
group by material;
MATERIAL | MAX_DAYS | MIN_DAYS | DIFF_MIN_MAX |
19395 | 800 | 50 | 750 |
Actually, this is so basic, that you should revisit your SQL course if this troubled you.
Anyhow, you also asked to store the result of the subtraction.
Why would you want to do that?
SAP HANA provides you with enough performance to calculate this on the fly. Even for lots of data.
Storing something like this is pretty much an anti-pattern for SAP HANA.
Therefore it would be really good to have a reason for this.
- Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
51 | |
6 | |
5 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.