google ads API , CONTAINS ANY is not a valid operator to use with 'ad_group.name' in WHERE clause - google-ads-api

I am trying to fetch google Adwords reporting data (clicks,cost..etc) of specific addGroup with Google Ads Query Language buts saying CONTAINS ANY is not a valid operator to use with 'ad_group.name',
here is my query
"query": "SELECT ad_group.name, metrics.impressions,metrics.clicks FROM ad_group where ad_group.name CONTAINS ANY ('pmp')"
I need to fetch similar addgroup by name similar to SQL like '%%',
there is a LIKE command in GAQL but its working like = , eg for add group = 'test-exam'
this works
"query": "SELECT ad_group.name, metrics.impressions,metrics.clicks FROM ad_group where ad_group.name LIKE ('test-exam')"
but this returns nothing
"query": "SELECT ad_group.name, metrics.impressions,metrics.clicks FROM ad_group where ad_group.name CONTAINS ANY ('test')"

You need to use the SQL percentage syntax for the LIKE statement in GAQL too.
So:
SELECT ad_group.name, metrics.impressions,metrics.clicks
FROM ad_group
WHERE ad_group.name LIKE '%test-exam%'
This works for me.
I think 'CONTAINS' only works with the older AdWords API.

Related

Using a subquery as a parameter

I am using Google Sheets and have a connected query where I am using parameters. When one of the parameters is configured to be a subquery, the query will run, but no results are returned.
For example, here is my (simplified) query:
SELECT *
FROM table
WHERE campaign IN (#CAMPAIGN);
In this example, I have the #CAMPAIGN parameter in the Google Sheet configured as:
SELECT DISTINCT campaign FROM table2
If I manually substitute the parameter in the BQ console, it runs fine and returns the expected results. Is there a reason this functionality does not work with parameter substitution in the Google Sheet? Is there a way around this?
Depending on how much SQL SELECT type lookups you do, it may help to use a #customfunction that I wrote. You need to place my SQL .js in your Google sheets project and the =gsSQL() custom function will be available.
The one requirement for this versus using =QUERY() is that unique column titles are required for each column.
It is available on github:
gsSQL github project
This example works if each sheet is a table, so it would be entered something like
=gsSQL("SELECT books.id, books.title, books.author_id
FROM books
WHERE books.author_id IN (SELECT id from authors)
ORDER BY books.title")
In this example, I have a sheet named 'books' and another sheet named 'authors'.
If you need to specify a named range or an A1 notation range as a table, this can also be done with a little more work...
=gsSQL("SELECT books.id, books.title, books.author_id
FROM books
WHERE books.author_id IN (SELECT id from authors)
ORDER BY books.title", {{'books', 'books!$A$1:$I', 60};
{'authors', 'authors!$A$1:$J30', 60}}, true)
In this example, the books and authors come from specific ranges, the data will be cached for 60 seconds and column titles are output.

Model.group(:id) throws an error "Select list is not in GROUP BY clause contains non aggregated column "id"

I am using Model.group(:category) in order to get unique records based on category field in Rails 5 application.
Table data:
id catgeory description
1 abc test
2 abc test1
3 abc test2
4 xyz test
5 xyz testabc
I want records (1,4) as a result. Therefore I am using Model.group(:category) which works fine for MYSQL whose sql_mode is " " .
Unforunately its throwing an error "SELECT list is not in GROUP BY clause and contains nonaggregated column which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by" whose sql_mode is "only_full_group_by".
whats the best way to change the query to match the mode?
Perhaps try specifying which id you want? You could use MIN(id), MAX(id) etc.
MySQL supports a non-standard extension to SQL described here. To continue using that behavior, you could change the sql_mode to TRADITIONAL in config/database.yml.

How to define query in solr

I am making a log searching service for business by solr.
I have some problem during query configuration.
I have below data.
message_type, mobile_no, ident_no, resultCode
||CCR, 01012345678, 1, null||
||CCA, null, 1, 5012||
I want to find all records with same ident_no by using mobile_no.
So, I am thinking sql statement like below.
SELECT A.*
FROM DATA
WHERE IDENT_NO IN (SELECT IDENT_NO FROM DATA WHERE MOBILE_NO = ‘01012345678’)
I defined below query for solr.
http://localhost:8983/solr/select?q={!join from=ident_no to=ident_no}mobile_no:01012345678
I didn’t receive the result by using query.
Is this query incorrect?
If you have added field mobile number in your schema.xml,then you can fetch the result by using query as mobile number : 1234567890

coalesce in IQ is not working

I am using something like this:
select #x=coalesce(#x,'')+col1 from testdatatable
This works perfectly on SQL Server 2008 but for IQ it fails:
SELECT returns more than one row
We need more information on what your goal is here.
Is your select statement returning multiple rows? If so, IQ is attempting to set a single (varchar?) variable, #x, with many values...which isn't possible. It doesn't look like coalesce is your problem to me.
If are you trying get a single row back from testdatatable, and concatenate that single row's col1 with the #x, why not
select
#x = isnull(#x, '') + col1
from testdatatable
where (clause to get single row)

Grails - how to pass list of values to a domain class

I am trying achieve the following SQL using Grails.
“Select * from table1 where col1=’COL1’ and col2 in(‘COL2_1’,’COL2_2’,….) and col3=1”
I can get the col2 map and not sure how to pass this map to the table1 domain
I try something like this
table1.findAllWhere(col1:'COL1', col2 :modelMap.COl2, col3:1)
Which is returning null.
I appreciate any help on this
Thanks
Bala
You can use HQL for this in pretty much a direct translation of that:
Map params = [col1: 'COL1', col2List: ['COL2_1', 'COL2_2', 'COL2_3'], col3: '1']
TableOne.executeQuery("""
select t1
from TableOne t1
where t1.col1 = :col1 and t1.col2 in (:col2List) and t1.col3 = :col3
""", params)

Resources