-1
Good afternoon, I’m having trouble with the group by clause.
I have a gigantic query, I need to quantify the contracts by Id, showing the degree of impact. Then I gave a Count(Id). The problem is that SQL doesn’t let me show the impact without adding this column to the GROUP BY clause. And when I put it, it separates by grouping first by impact and then by Id, as in the example below:
Id(int) - Quantity(int) - Impact (string)
5 - 3 - High
5 - 6 - Low
3 - 2 - High
2 - 1 - Low
But in reality, I would need it here:
Id(int) - Quantity(int) - Impact (string)
5 - 9 - High
3 - 2 - High
2 - 3 - Low
The comparison I need to make is "if the ID is duplicated, then add up the quantities and consider the greater impact between the records; if it is duplicate, consider whatever is in the record" Is there any way you can already do this grouping in the query?
Or I need to do it in C# ?
PS: This table is fictitious, actually thousands of records
Thank you
I switched to numeric variable and it worked!
– niknight89
thank you so much!
– niknight89