Skip to content

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…

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 …