Skip to Content
0
Former Member
Oct 01, 2013 at 05:32 AM

SAP HANA SQl Query

671 Views

Hi

I have this query

Select
A.CalDay,
Sum(Case When Left(A.Suffix,1) = 'B' Then
(Case when A.SK_400ID is null Then
Max(A.QualityScore)
Else
(Select Min(C.QualityScore)
From DATAINT.TBL_NEM400 B, DATAINT.TBL_QUALITYSCORE_LU C
Where A.SK_400ID = B.SK_400ID
And Left(B.QualityMethod,1) = C.QualityMethod
Group By B.SK_400ID)
End)
Else
0
End) As NewQualityScore_B,
Sum(Case When Left(A.Suffix,1) = 'E' Then
(Case when A.SK_400ID is null Then
Max(A.QualityScore)
Else
(Select Min(C.QualityScore)
From DATAINT.TBL_NEM400 B, DATAINT.TBL_QUALITYSCORE_LU C
Where A.SK_400ID = B.SK_400ID
And Left(B.QualityMethod,1) = C.QualityMethod
Group By B.SK_400ID)
End)
Else
0
End) As NewQualityScore_E


From DATAINT.TBL_SMAPROF A

Where NMI = '2001000639'
And CalDay >= '2013-07-01'
And CalDay < '2013-09-29'

Group By A.CalDay,A.SK_400ID

Order by A.CalDay

Which gives me this error

Could not execute 'Select A.CalDay, Sum(Case When Left(A.Suffix,1) = 'B' Then (Case when A.SK_400ID is null Then ...' in 6 ms 444 µs . SAP DBTech JDBC: [279] (at 102): group function is nested: line 5 col 5 (at pos 102)

Any sugestions on how I can do this. I have been doing this by puting the Suffix part in the where clause but that is to slow

Thanks MarkS