var report = AdWordsApp.report(
'SELECT Id, Criteria, CpcBid, FirstPageCpc, FirstPositionCpc, TopOfPageCpc, Criteria ' +
'FROM KEYWORDS_PERFORMANCE_REPORT ' +
'WHERE' +
'Id = 14317961 ' +
'DURING LAST_7_DAYS ');
var rows = report.rows();
while(rows.hasNext()) {
var row = rows.next();
var keywordIdReport = row['Id'];
var keywordNameReport = row['Criteria'];
var cpcBid = row['CpcBid'];
var firstPageCpc = row['FirstPageCpc'];
var firstPositionCpc = row['FirstPositionCpc'];
var topOfPageCpc = row['TopOfPageCpc'];
Logger.log('KeywordIdReport :' + keywordIdReport)
Logger.log('CPCbid :' + cpcBid)
Logger.log('firstPositionCpc : ' + firstPositionCpc)
Logger.log('topOfPageCpc : ' + topOfPageCpc)
Logger.log('firstPageCpc : ' + firstPageCpc)
}
I don't understand why, but the Adwords IDE tell me that the condition WHERE Id = 14317961 in my query is invalid, but I can't explain it is wrong. Assume here that the current Id exists. The purpose of that query is to access the three fields firstPositionCpc, topOfPageCpc and firstPageCpc for the specific keyword id. How could I fix my problem?
Try giving a space after your where clause 'WHERE ' +.
There is no space after the 'WHERE' +
Add a space after it 'WHERE ' +.
missing space after " WHERE "
var report = AdWordsApp.report(
'SELECT Id, Criteria, CpcBid, FirstPageCpc, FirstPositionCpc, TopOfPageCpc, Criteria ' +
'FROM KEYWORDS_PERFORMANCE_REPORT ' +
'WHERE ' + <----- space was missing
'Id = 14317961 ' +
'DURING LAST_7_DAYS ');
In your query, no spaces are available between 'where' and 'ID', please add a space between those.
'WHERE ' +
'Id = 14317961 ' +
You are just missing the space after the WHERE keyword, it should be as shown below:
var report = AdWordsApp.report(
'SELECT Id, Criteria, CpcBid, FirstPageCpc, FirstPositionCpc, TopOfPageCpc, Criteria ' +
'FROM KEYWORDS_PERFORMANCE_REPORT ' +
'WHERE ' +
'Id = 14317961 ' +
'DURING LAST_7_DAYS ');
Related
I'm trying to insert and values into my database and I thought having the same name for the inputs in my form would make it easier for me to insert them in bulk, I want to iterate OrderNo and quantity and insert them to a new column while keeping the other inputs such as fname the same until the values in OrderNo are done.
app.post("/send-data", (req,res)=>{
let sql = "INSERT INTO foodorder.orders (" +
"food_id," +
" qty,"+
" customer_FName," +
" customer_LName," +
" customer_number," +
" customer_email," +
" customer_facebook," +
" order_date," +
" delivery_option," +
" mode_of_payment," +
" delivery_time" +
") VALUES (" +
` ${req.body.OrderNo},` +
` ${req.body.quantity},` +
` "${req.body.fname}",` +
` "${req.body.lname}",` +
` "${req.body.Contact}",` +
` "${req.body.email}",` +
` "${req.body.facebook}",` +
` "${req.body.date}",` +
` "${req.body.delivery}",` +
` "${req.body.payment}",` +
`"${req.body.time}"` +
`)`;
con.query(sql, (err,result) => {
if(!err){
res.send(result);
}
else{
res.json(req.body);
throw err;
}
})
});
This is the code that I have and currently it only accepts 1 OrderNo and quantity and when I try to order many products with different quantities it will say column count doesn't match
value count at row 1 (see attached photo below)
[the output i get from my forms *I didnt include in the screenshot the other output details such as email etc.][1]
is there a way to just iterate the OrderNo and quantity and insert them creating new columns but with the same fname and lname etc.? or do i need to use MySql cursor?
Note that my code works and inserts if i only have selected 1 order and 1 quantity in my forms
UPDATE
Attached here is what I wanna achieve. I wanna know a way to iterate or loop the OrderNo and quantity and insert them into their respective columns while keeping the other values the same like fname and lname.
I wanna achieve this
Fixed by iterating the OrderNo. Thanks so much Diogo
app.post("/send-data", (req,res)=>{
let order = req.body.OrderNo;
let quantity = req.body.quantity;
let first = req.body.fname,
last = req.body.lname,
contact = req.body.Contact,
email = req.body.emailAdd,
fb = req.body.facebook,
date = req.body.date,
delivery = req.body.delivery,
payment = req.body.payment,
time = req.body.time,
address = req.body.address;
[order].forEach((product, index, arr)=>{
const q = quantity[index];
let sql = "INSERT INTO foodorder.orders (" +
"food_id," +
" qty,"+
" customer_FName," +
" customer_LName," +
" customer_address," +
" customer_number," +
" customer_email," +
" customer_facebook," +
" order_date," +
" delivery_option," +
" mode_of_payment," +
" delivery_time" +
") VALUES (" +
con.escape(product) + `,` +
con.escape(q) + `,` +
con.escape(first) + `,` +
con.escape(last) + `,` +
con.escape(address) + `,` +
con.escape(contact) + `,` +
con.escape(""+email) + `,` +
con.escape(fb) + `,` +
con.escape(date) + `,` +
con.escape(delivery) + `,` +
con.escape(payment) + `,` +
con.escape(time) +
`)`;
con.query(sql, (err,result) => {
if(!err){
res.redirect('thankyou.html');
}
else{
res.status(404).send('ERROR. Please Go back and Order Again');
}
})
})
});
In this case i want to null check by using column IS NULL..here column specify uniquename.
Uniquename is a integer column.
filterExpression = objColumnSettings.UniqueName + ' <> ' + objColumnSettings.FilterValue + ' AND ';
Here i have done like this.
This works but i want to use column IS NULL rather than ISNULL(column, value)
filterExpression = " ISNULL( " + objColumnSettings.UniqueName + " , 0 ) " + ' <> ' + objColumnSettings.FilterValue + ' AND ';
Please suggest
Thanks in advance;
should be
filterExpression = objColumnSettings.UniqueName + " IS NUL OR " + objColumnSettings.UniqueName + ' <> ' + objColumnSettings.FilterValue + ' AND ';
When using UNION or UNION ALL in a GROUP BY query using alasql (https://github.com/agershun/alasql), only results from table1 are retrieved.
Running separate queries outputs correct results instead.
See this jfiddle http://jsfiddle.net/L8471bnk/116/
var data= [
{"label":"transport - car","value":800},
{"label":"airplane","value":234},
{"label":"train","value":500},
{"label":"glider","value":123},
{"label":"transport - motorbike","value":50},
{"label":"transport - bike","value":150}
];
var query1 = alasql('' +
'SELECT \'transport\' AS label, SUM(CAST([value] AS INT)) AS [value] ' +
'FROM ? ' +
'WHERE label LIKE \'%transport%\' ' +
'GROUP BY \'transport\' ' +
'',
[data]);
var query2 = alasql('' +
'SELECT label, SUM(CAST([value] AS INT)) AS [value] ' +
'FROM ? ' +
'WHERE label NOT LIKE \'%transport%\' ' +
'GROUP BY label' +
'',
[data]);
var queryUnion = alasql('' +
'SELECT \'transport\' AS label, SUM(CAST([value] AS INT)) AS [value] ' +
'FROM ? ' +
'WHERE label LIKE \'%transport%\' ' +
'GROUP BY \'transport\' ' +
'UNION ALL ' + //or UNION, same result!
'SELECT label, SUM(CAST([value] AS INT)) AS [value] ' +
'FROM ? ' +
'WHERE label NOT LIKE \'%transport%\' ' +
'GROUP BY label' +
'',
[data, data]);
$("#res").html("<br/>UNION IS WRONG (length is correct, but query2 results are missing!!!)!<br/>" + JSON.stringify(queryUnion) + " LENGTH: " + queryUnion.length);
$("#info").html("<br/>Query1 is correct:<br/>"
+ JSON.stringify(query1)
+ " LENGTH: " + query1.length
+ "<br/><br/>Query2 is correct<br/>" + JSON.stringify(query2)
+ " LENGTH: " + query2.length);
Just found out: it seems like it's a bug?
See https://github.com/agershun/alasql/issues/485
:(((
I am using jQchart to display a graph. However, the title property seems to display only a single line of text. Currently, the graph displays the following title:
text: chartTypeText + ': ' + chartTitle + ", " + $('#baselineResidentialLocationCity option:selected').text() + ', ' + $("#baselineResidentialLocationState option:selected").val() + ' ' + $('#baselineResidentialStandardYear option:selected').text() + ' ' + baselinePeriod + ' year'
However, I basically need to display each variable on a different line (hopefully use linebreaks to separate each piece of information). I tried using "" but it displays the string literal.
Is there any way I could display each variable under the title of the graph with different fonts etc?
If you are looking for series title customization, it can be customized with tooltipFormat event.
[Use some separator(I use ; as a separator) and format with html, css]
In below statement, I changed separator to ;
text: chartTypeText + ': ' + chartTitle + ";" + $('#baselineResidentialLocationCity option:selected').text() + ', ' + $("#baselineResidentialLocationState option:selected").val() + ';' + $('#baselineResidentialStandardYear option:selected').text() + ' ' + baselinePeriod + ' year'
<script lang="javascript" type="text/javascript">
$(function () {
$('#ChartClientID').bind('tooltipFormat', function (e, data) {
var t=data.series.title.split(";");
//OR here you can dynamically build here it self
return "<b>" + t[0] + "</b><br />"
+ (t[1] || "") + "<br />"
+ (t[2] || "");
});
});
</script>
see this link for reference: http://www.jqchart.com/aspnet/chart/ChartFeatures/Tooltips
I'm trying to preserve Javascript context from an array. Is there any way to make this work? Or a more elegant way?
EXAMPLE:
<html>
<script type="text/javascript">
var rand = Math.floor(Math.random() * 6) + 1;
var i = Math.floor(Math.random() * 6) + 1;
var arr = ["'There are ' + i + ' dogs in the yard.'","'The other day I saw ' + i + ' pigs that one lake.'","'I can't believe there were ' + i + ' birds in your yard the other day.'","'Why were there ' + i + ' cats in my front yard?'","'There are ' + i + ' rabbits in the yard.'","'There are ' + i + ' snakes in the yard.'"];
document.getElementById('fudge').innerHTML = arr[rand];
</script>
<body>
<div id='fudge'></div>
</body>
</html>
Get rid of the outer double quotes.
var arr = [
'There are ' + i + ' dogs in the yard.',
'There are ' + i + ' pigs in the yard.',
'There are ' + i + ' birds in the yard.',
'There are ' + i + ' cats in the yard.',
'There are ' + i + ' rabbits in the yard.',
'There are ' + i + ' snakes in the yard.'
];
Update: Also, place your <script> somewhere below the fudge element. Currently the script is running before fudge exists.
If you want the strings to update with future updates to the variable, that won't work. You'd need to generate a new string.
You could make a function instead.
var animals = ['dogs','pigs','birds','cats','rabbits','snakes'];
function makeString() {
var animal = animals[Math.floor(Math.random() * animals.length)],
qty = Math.floor(Math.random() * 6) + 1;
return "There are " + qty + " " + animal + " in the yard.";
}
makeString(); // "There are 3 dogs in the yard."
You could also take care of the singular/plural grammar value when the qty is 1.
var animals = ['dog','pig','bird','cat','rabbit','snake'];
function makeString() {
var animal = animals[Math.floor(Math.random() * animals.length)],
verb = 'is',
qty = Math.floor(Math.random() * 6) + 1;
if (qty !== 1) {
animal += 's';
verb = 'are';
}
return "There " + verb + " " + qty + " " + animal + " in the yard.";
}
makeString(); // "There is 1 dog in the yard."
I assume that you want to use the variable i to create the strings, not just the letter i. As you use quotation marks around the strings, the variable isn't part of the string.
Instead of:
"'There are ' + i + ' dogs in the yard.'"
just use:
'There are ' + i + ' dogs in the yard.'
or:
"There are " + i + " dogs in the yard."