The above query gives me the data like I want the count of employees and total of each of the above columns in the below format – what function should I use for this ? Answer
Tag: sql
Query SQL values with possible empty records
I have 4 tables that I want to run a single query on. I want specific values from each table that all relate to a single user. However, some of these tables may not have any associated records. If there are no records in a given table, the query set comes back as empty (because there are no records pertaining
Oracle SQL – Sum next X number of Rows
I have a table in Oracle database whith projected sales per week and would like to sum the next 3 weeks for each week. Here is an example of the table for one product and what I would like to achieve in the last column. I tried the Sum(Proj Sales) over (partition by Product order by Date), but I am
Create category column mysql
I have a transactions table, I want to query it using MySQL 5.7 group by vendor and count number of transaction, and categorize vendor by these criteria Great: More than 2 SHIPPED and 0 CANCELLED transactions OK: More than 2 SHIPPED and 1 or more CANCELLED transactions Mediocre: other than Superb and Good cri…
SQL query to filter records based on count and status
I have to filter records based on the status when the count is more than 1. Column names: Student_id, Status, term, and course. DB: Postgres Condition to filter: If there exists only one record for the student then the status(true or false) does not matter. Fetch the record. If record count for a student is m…
how to find the position of string search in a json array column in laravel
i have a query which returns boolean value from a json array column about whether the string i am searching exists or not the column is something liek this —— [“a”,”b”,”c”] and the query is below but i want to get the position where the string was found… l…
SQL getting the minimum out of calculation of 3 values
I have multiple rows that each have 3 columns and what I want to do is calculate these 3 columns at each row and see which row has the lowest sum for example: row 1 – col1(1)+col2(3)+col3(0) = 4 row 2 …
Need to find string using bigquery
We have below string column and having below data and I want to find Null count present in string columns means how many times null value(”) present in front of id column present in select statement using big query. Don’t use string position. Expected output: Answer Below is for BigQuery Standard …
How many SQL Queries will be executed in the database through this EF
I have the following and want to know how many queries will be executed in the DB through this EF? private static dbContext dbc = new ProfileDBC(); private static IQueryable GetProfile(…
mariadb/mysql Nested `WITH` statement causes table-not-found error
I am not sure if this is a documented limit in mariadb or a bug in its query parsing. We are porting some enormous queries from vertica to mariadb, and I have encountered cases where queries with …