I have a SELECT query as below: This query gives me an output like this: My question is, how to filter the 0 due records from due_balance and modify the query to get the rest? Expecting result should be: I tried it in this way, but it doesn’t work for me. Answer Use HAVING Clause or use subquery then add
Tag: select
Average per hour adding an empty record if data is missing
I have this data: I need to store the average of each hour in a second table. I don’t know if I can also insert a NULL record if there is no data for an hour, maybe in a second treatment. I have tried with this first treatment but can’t do it. I get an error message and don’t know
SQL Query between a date range and a time range in MariaDB
I’m having trouble writing this query to give me any results. I’m using MariaDB as well. The DATE_ADD clause works just fine and gives results within that interval, but as soon as I add in the TIME function nothing is returned in the results. The CallDate format is 2021-09-21 HH:MM:SS I have tried using HOUR as well in place of
How do I merge OUTER JOIN and UNION results?
I have two tables, and I want ALL the data from both. If the tables have a matching AssetID, then join them on one row. If not, then on separate rows. A full outer join sounds like the right approach but I have a problem in how to select the keys depending on which table it comes from. Goal: Produces
Getting not valid month in Oracle sql
I have a table called Transactions that has a column called trans_date. I am just trying to do a simple query in the SQL*Plus command window The query is When I run this query I get not valid month and there is a little * under trans_date. Most of what I have read suggests the query is right but I
SQL complicated SELECT query
I would like to have a select query, where I get all the games that a specific user played with the points of his and the opponents team. Entity relatioship model of my database This is my current query: The current query gives me this result: userId gameId won points 1 1 true 19 Problem: From this query I only
Single Query To Select Based On Parameters If Or not supplied
I have used SqlDataSource and have a select query based on District & Zone as below It’s an inline query. I have tried above query but not able to figure out how to Select condition based. I want if district supplied then Select according to District, if both District & Zone supplied then Select according to both & If nothing
How to return data for specific day names from date column
Imagine I have a SQL Server table as shown below, named dbo.tblNAV: How can I select the data only for Mondays and Fridays? I am a beginner in SQL Server and almost have no idea to handle this. I would appreciate your help. I am using Microsoft SQL Server Management Studio. Answer SQL Server does not make this easy to
MySQL procedure not working with both select and delete
I created a procedure to get a vehicle id from the vehicle table using vehicle number input, then delete the booking record for that vehicle id, and at last to delete the entry in the vehicle table… But when creating the procedure I get an error at line 7 saying Error Code: 1064. You have an error in your SQL
sqlite3 INSERT INTO UNION SELECT
Table columns: pk is the auto-incrementing primary key An error occurs when I execute this SQL DB Error: 1 “table table1 has 4 columns but 3 values were supplied” Answer You should explicitly specify which columns in table1 your insert is targeting: When you omit the select list entirely, SQLite will fall back to expecting values for all columns in