Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 salary range

Author  Topic 

simflex
Constraint Violating Yak Guru

327 Posts

Posted - 2004-06-20 : 17:17:11
I am been struggling with this now for awhile.
Perhaps, someone might have an answer.

I am trying to perform a where clause search with salary.

I have one field on the database calle sal with datatype called currency.

I need to pull names of those who are in some income bracket.

So I go:

Dim salary,selDate
salary = rst("sal")
selDate = rst("fdate")



' Build our query based on the input.
strSQL = "SELECT id,sal, min(sal) as beginSal,max(sal) as EndSal, min(fdate) as BeginDate, max(fdate) as EndDate,companyName, address,city,minorityStatus," _
& " state,zip_code,county,phone,faxnumber,incomeRevenue,employeeNumber, " _
& "headquarter,sic,naic " _
& "FROM sample " _
& "WHERE companyName LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR zip_code LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR phone LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR headquarter LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR city LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR Address LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR county LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR sal = " & salary & " " _
& "OR fdate = '# & selDate & #' _
& "OR minorityStatus LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "GROUP BY id,companyName,address,city, minoritystatus,state,zip_code,county,phone,faxnumber,incomeRevenue,employeeNumber,headquarter,sic,naic,incomeRevenue " _
& "ORDER BY companyName;"

First, I am getting type mismatch on the declaration of salary and date here:
Dim salary,selDate
salary = rst("sal")
selDate = rst("fdate")


Then I am getting wrong expression here:


& "OR sal = " & salary & " " _
& "OR fdate = '# & selDate & #' _
Can anyone, please help,
thanks in advance

drymchaser
Aged Yak Warrior

552 Posts

Posted - 2004-06-21 : 08:58:57
Not sure, but to me this:

& "OR fdate = '# & selDate & #' _

should be this:

& "OR fdate = #" & selDate & "# " _
Go to Top of Page
   

- Advertisement -