Skip to content

Tag: sql

Adding all dates to SQL query for grouped dates

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…

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…

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…

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 …