0

What is the right way to add an apostrophe to my select query in Google Spreadsheets?

I wan't to count how much entries there are with this string:

Today's 

Current output:

#VALUE! 

My query:

select Count(F) where F = 'Today's' Label Count(F) ''

="select Count(F) where F = '"&A3&"' Label Count(F) ''"
Rover
  • 387
  • 4
  • 14
  • 1
    Doesn't [this question](http://stackoverflow.com/questions/1586560/how-do-i-escape-a-single-quote-in-sql-server) help you? – Beytan Kurt May 27 '15 at 07:35
  • Thanks, but I'm still not sure how to use this with this query? Where do I have to place the extra quotes? ="select Count(F) where F = '"&A3&"' Label Count(F) ''" – Rover May 27 '15 at 07:56
  • It's working now! Query is: ="select Count(F) where F = """&A3&""" Label Count(F) ''" – Rover May 27 '15 at 08:01

1 Answers1

0

It is already explained in this question. But you just have to use double quotes to escape in most cases like

Select 'Mike''s car'

Here is a simple example:

CREATE TABLE Test (
  Name VARCHAR(25), 
  LastName VARCHAR(25), 
  Department VARCHAR(50)
);
insert into Test (Name, LastName, Department)
values 
  ('John', 'Doe', 'Something''s Department'),
  ('Jane', 'Doe', 'Another One''s Department');

select * 
from Test
where Department = 'Another One''s Department'

Working example in sqlfiddle

Community
  • 1
  • 1
Beytan Kurt
  • 2,203
  • 4
  • 34
  • 57