Re: A difficult SQL problem... please help
Date: 1998/06/24
Message-ID: <6mri00$7kg$1_at_goo.nwd.usace.army.mil>#1/1
I would write a quick function to provide the groupings:
Function fSalaryGroup(dSalary As Currency) As String
Dim sRet As String
Select Case dSalary
Case 0 To 1000 'etc. sRet = "<1000" Case Else sRet = ">1000"
End Select
fSalaryGroup = sRet
End Function
Then the query would just be like:
SELECT Table1.Sex, fSalaryGroup([Salary]) AS SalaryGroup, Count(*) AS SGFreq FROM Table1 GROUP BY Table1.Sex, fSalaryGroup([Salary]);
there might be an easier way to just do it all in a query, but I (sometimes unfortunately) think in terms of code not SQL....
HTH,
Tim
Lee Ka Wo wrote in message <3590FAC3.197F_at_netvigator.com>...
....
>If I have a tables full of salary., I need to group them into several
>salary "ranges" like this:
>
> <1000 >=1000 to < 2000 >=2000 to <=2500 >2500
>
>Male 100 200 120 50
>Famale 50 222 30 65
>
Received on Wed Jun 24 1998 - 00:00:00 CEST