My database design is seen as below: I’m interested in finding out what questions are in what questionnaire. So I tried the below in order to output what questions were held inside of the …
Tag: sql
Case when column a from tableX is present in column b of tableY
Below is my use case, i’m querying redshift tables, using case when but get error in case when statement. ERROR: Statement 2 is not valid. ERROR: syntax error at or near “b” MY SQL query: CREATE …
PostgreSQL-10: query JSONB property with multiple types
Assume a table json_table with a column data (jsonb). A sample value would be {“a”: [{“b”:{“c”: “xxx”, “d”: 1}},{“b”:{“c”: “xxx”, “d”: 2}}]} I used to run SQL queries like the following: SELECT …
Add new column to result and coalesce table
DB Fiddle CREATE TABLE logistics ( id int primary key, campaign VARCHAR(255), event_type VARCHAR (255), date_offered VARCHAR (255), date_ordered DATE, date_delivered DATE, …
How to compute duration between two times in postgresql when the end time is sometimes past midnight
I have to compute the duration of events in postgres based on start_time and end_time, both are in the HH:MM:SS format. Simply end_time – start_time works: create table test_date as select sum(…
A problem with SQL when selecting data from two tables
i need to have this result order_num amount name ———- ———- ————— 70007 948.5 Graham Zusi 70010 1983.43 Fabian Johns from this tables (examples): …
How to implement pagination by nextPageToken?
I am trying to implement pagination using nextPageToken. I have table: CREATE TABLE IF NOT EXISTS categories ( id BIGINT PRIMARY KEY, name VARCHAR(30) NOT NULL, parent_id …
Chances of SQL injection in dynamically constructed SQL
I have a query like this in MySQL val selectQ = “SELECT NAME FROM EMPLOYEE” val date = “2010-10-10” val age = 10 Now I have some dynamic AND clauses, like val whereNameFilter = “WHERE date = $…
SQL & Pandas Efficiency [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question Quick question. What is the rule of thumb when deciding where to begi…
How do I update if exist, else insert in MySQL
I have table with AUTO_INCREMENT field defined as PRIMARY_KEY. I have columns like: vote_id,vote_user_id,vote_ask_id,vote_comment_id,vote_post_id,vote_type,vote_status I want to INSERT new records but before I do that I want to check if there is a row with columns(vote_user_id,vote_ask_id,vote_type) as same a…