I would like SQL to return all dates, whether or not they are null or 0 from the following query: Current Output: Desired Output: I do not have another table with dates to reference My min should be the first date pulled from the query (in this case, 01/02/22) and then my max should be the most recent date th…
Tag: sql
Joining Query with codeigniter Model
Please help me how can I get only response where activities.activity_id = response.activity_id? here is my CI_model My Activities table My Response Table My users table Answer Try with this: You need to add aliases to the tables in order to build a more simplified and ordered query, in this case the aliases a…
How to make a join with the same table to insert the maximum column value?
I have a table that keeps activity records, containing the date of registration and other information about the activity performed. I would like to make a query that would return one more column in the table, containing the maximum record date. I don’t think it’s too complicated, but my knowledge …
Find groups containing 6 consecutive 1s in one column
I have a table with 2 columns: val with values: 0 or 1 id with unique identifiers How do I to find id with 6 values = 1 in a row. In the example above: id = 9, id = 10. It is desirable not to use loops (cursors or while), but something like sum(…) over(…). Answer You can use
Why is json_extract_scalar returning null
I have a fairly simple string-formatted json column in a BigQuery database I am trying to flatten. id relationships 1 {‘ownerObject’: {‘data’: None}, ‘investmentObject’: {‘data’: {‘type’: ‘assets’, ‘id’: ’40’}}, &#…
In SQL I Want Result Like
Select * from CompanyName This Is My Output I Want To Add 1 In Last Same Filed Like Answer The following solution is appropriate for the question asked: Output : Just keep in mind that this is not a good solution for big tables and operational data in your database
How to calculate percentages in a group using SQL
Suppose I have a table employee (ID, status, department) Suppose the status can only be ‘f’ or ‘c’. How to calculate the % of f’s and c’s in each department? Update 1: the four fields in the output should be A. DEPTNAME B. F_PCT C. C_PCT D. EMPCOUNT in that Dept Update 2: s…
regex to find “null” values from a column
I have a column JSON_DATA. The values within this column have an object type. It contains a json. This query works fine: This is how the data might look like: Some of the values within this field are “null”. I want to search all occurrences of quoted “nulls” and replace/regex_replace t…
How to correctly join two tables that each have Start Date and Stop Date columns?
This should be easy, maybe even a duplicate, but neither my brain nor my search engine is being very helpful today. My problem is as below: Given two tables that both have: A start date A stop date A property of an employee. Let’s say Desk Number in table A and Team in table B The employee’s uniqu…
MS Access – Selecting which table to merge
Is there a way to choose which table do I merge using SQL in MS Access through entering parameter value? Let’s say I have 3 tables: Users, 2021 and 2022. Any my query is: I get “Enter Parameter Value” window to filter the code that I want to check, but I would like to get the same to choose …