I have an employee table that looks like this: I needed to get the minimum value and maximum value of questions where the id is equal to 4. In this case, I needed 5 and 25 returned. I acheived that using the following query: But what this doesn’t return is the question id. How can I adjust my query to
Tag: sql
BigQuery SQL for 28-day sliding window aggregate (without writing 28 lines of SQL)
I’m trying to compute a 28 day moving sum in BigQuery using the LAG function. The top answer to this question Bigquery SQL for sliding window aggregate from Felipe Hoffa indicates that that you can use the LAG function. An example of this would be: Is there a way to do this without having to write out 2…
Trying to get value out of a select option in the same form
I’m trying to get value out of the select option. But it doesn’t seems to be able to get since it’s on form. How do I do it ? I mean by having taking the value out of the option select. Answer 1.) You can not select all the items in a select with selected ! Without multiple=”multiple&#…
Retrieve rows in which a column doesn’t contain a value
I have a MySQL table like below: | ID | userIDs ————— | 1 | 4,3,5 | 2 | 2,3 | 3 | 1,2,3 I want to retrieve all the rows in which userIDs doesn’t contain 1. I tried SELECT * …
explain differences between two different updates
I have 2 different update queries, one I created: my colleague preferred this one: He can’t explain which one should be better and neither can I. The only difference I have, is that the update on the second query crashes when there are no results to update. Can anyone explain what’s the difference…
How to use LIKE with ANY in Postgresql?
Is there a way to do a partial string match on a string array column in postgres? I’m trying the following syntax, but it is not working as I’d expect it to: Is there a correct way of doing this? Answer
jOOQ: Mocking DAO objects
jOOQ 3.5.0 I’m currently trying to write unit tests for a resource that is using jOOQs generated DAO objects. I’ve noticed one of the base classes (DAOImpl) in the DAO hierarchy has many final methods which makes it unfriendly to mock (I’m excluding byte code manipulators like Powermock as a…
Compare row count of two tables in a single query and return boolean
I want to compare row count of two tables and then return 0 or 1 depending on whether its same or not. I am thinking of something like this but can’t move ahead and need some help. I am getting multiple rows instead of a single row with 0 or 1 Answer you have to remove : Otherwise it will
how to set N prefix before sql parameter
i writed a query like this: SELECT [FirstName], [LastName] FROM [WorkersView] WHERE ([FirstName] LIKE ‘%’ + N’علی’ + ‘%’ ) AND ([LastName] LIKE ‘%’ + N’مسروری’ + ‘%’) and it’s work very well! and …
Running sqlplus in background in Unix
I am trying to run an .sql file from sqlplus in Unix environment as a background process. I am connecting to Unix using Tectia or Putty, and I want sqlplus to continue running in background even if my terminal closes. This command works but when trying to start it in background it fails What is the right comm…