I have this table: create table products(name text, quantity int); insert into products values (“A”, 10); insert into products values (“B”, 0); insert into products values (“C”, 15); insert into …
Tag: sql
SQL – Compare 2 tables with dates [closed]
I have 3 tables with are the following: st with an id, startDate, endDate, customer_id and serivcedeal_Id. servicedeal with id and name. price with id, price, startDate and servicedeal_Id. I have …
How do I print dynamic sql constraint error statement
I am working on odoo 11 and I want to change the error states of the following SQL constraint and print a dynamic error statement which shows the field “number” inside the error message. from odoo …
how to add 30 minutes in last value of return query using oracle?
My query is Select class_time from tableA which produces: 0200AM 0230AM 0300AM 0330AM 0400AM i want above result as 0200AM 0230AM 0300AM 0330AM 0400AM 0430AM
Data model guidance, database choice for aggregations on changing filter criteria
Problem: We are looking for some guidance on what database to use and how to model our data to efficiently query for aggregated statistics as well as statistics related to a specific entity. We have different underlying data but this example should showcase the fundamental problem: Let’s say you have da…
Presto how to find start date given week
I want to find start date from given ISO week (which can range from 1-53, Monday as starting day) and year using Presto SQL query. i.e. year – 2020 and week – 2 should return 06/01/2020 Is there any inbuilt function for this ? Table structure: Answer There’s no direct way for constructing a …
SQL UNION Query with Extra uncommon Field in Results
I have Four table, Now I display four common field using UNION sql query. Question : I want to display one uncommon field ( Company ) which in table name as Multiple Product with current result.How can I do it ? Current SQL : Answer You can just add an empty (or NULL) field to the other SELECT queries in
How to store tags for a blog article in SQL database?
I currently am working on developing a blogging website. For this application we’re using MySQL as the database. For this application,I created a blog table which contains the following properties: id blog_title content user_id updated_at upvotes I want to add tags to this table. What is the recommended…
How do i sum two query with each count and criteria in it
I have this two query sql and i’m trying to do a sum of both 2 counts in the query together but when i try to do the UNION ALL but it kept prompt me to enter parameter for CountOfTools_Number2. All i wan is the sum of the two count and return me a value. Answer Presuming your two example
Running total over duplicate column values and no other columns
I want to do running total but there is no unique column or id column to be used in over clause. there are only 2 columns, name which has duplicate values and the no on which I want to do running total in SQL Server 2017 . expected result: Any help? Answer The following query would generate the output you