Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "%()s" means in sql query?

Can somebody help me with this query? I don't have deep knowledge in SQL. What does these two lines mean in query?

HIT_DAY = TO_DATE(%(date)s,'MM-DD-YYYY')
ss.weblab_name = %(experiment)s

Is date and experiment some kind of parameters that I should pass into query? Why they ending with "s" ? How to pass this parameters?

This is whole query:

SELECT 
    session_count,
    treatment
FROM 
    SESSIONS ss
WHERE 
    HIT_DAY = TO_DATE(%(date)s,'MM-DD-YYYY')
AND
    ss.weblab_name = %(experiment)s
GROUP BY
    ss.treatment_name
;
like image 824
Bilberryfm Avatar asked Dec 08 '25 21:12

Bilberryfm


1 Answers

Some SQL IDE's such as Datagrip and Redash use those type of things to indicate that a user parameter could be entered. see https://www.jetbrains.com/help/datagrip/user-parameters.html http://help.redash.io/article/44-query-parameters

Some applications use that kind of format to indicate where data should be put when dynamically creating a query (so that would be a query template)

It is likely that they will be just string substitution so %(experiment) may resolve to widget but the column name might be widgets. or there may be something else but it will be dependent entirely on the application that is using these. Not Redshift.

like image 135
Jon Scott Avatar answered Dec 11 '25 12:12

Jon Scott



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!