Thread: SQL with 's and percentages
07-06-04, 20:37 #1Registered User
- Join Date
- Nov 2002
Unanswered: SQL with 's and percentages
Does anyone know how to write the WHERE Clause of an SQL statement to allow for the possibility of apostrophes( ' ) appearing in the text field that you are searching? Just a few of the names have these and the typical "name = '" & name & "'" doesn't work because the apostrophe in the name screws it up.
Secondly, I am trying to make a report with Client and GrossSales on it(ordered by GrossSales descending). The bosses want me to organinze these GrossSales by 10 percent categories..ie first 10%, sum of grossSales for that ten percent, next 10%(11%-20%), sum of GrossSales for that, etc. This percentage is on the amount of records returned by the query not percentage of total gross sales for the year or something. So, if there were 1000 records returned by my query, they would want to show the first 100 records with the highest GrossSales, then a total of GrossSales for these 100, then the next 100 records...etc. I know how to do the top values part of a query, but I am stumped as to how to make that show the second 10%, third 10%, etc. Thank you for your time and replies
07-06-04, 22:27 #2Registered User
- Join Date
- Sep 2003
- The extremely Royal borough of Kensington, London
where name = "user's"
2) To obtain results 11-20
select top 20 key
from tableA ta
where ta.key NOT IN
(select top 10 key
from tableA)Bessie Braddock: Winston, you are drunk!
Churchill: And Madam, you are ugly. And tomorrow, I'll be sober, and you will still be ugly.