I have a problem that I need to identify how many companies participated in a given project number. For example, identify which companies participated in exactly 2 projects.
Given the base below:
id company project
1 company1 project1
2 company2…
I am trying to query set result set which returns something like the below.
I need to return only 1 row per name and need to GROUP BY but only the name that have a value of '8' under the Grade column are desired. The below is a result from another…
I'm looking to filter out rows in the database (PostgreSQL) if one of the values in the status column occurs. The idea is to sum the amount column if the unique reference only has a status equals to 1. The query should not SELECT the reference at…
I've below data in MigratoryBirds table in SQL Server
birdType
1
4
4
4
5
5
5
3
SQL script to create above table:
/****** Object: Table [dbo].[migratoryBirds] Script Date: 20-Jul-17 8:01:02 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER…
Here is the minimized version of the Customer table. There can be customers having same account number mapped to different Group . I am looking to find out customer numbers which are mapped to more than one group. As I was using sybase my query…
I need to execute some SQL that looks like this:
select approve_firm_id,approve_dt,approve_result
from main_approve
group by approve_firm_id
having MAX(approve_dt) and approve_result=0;
it runs (mysql-5.1),
but if I try in the Django model like…
I'm having difficulty with a query which displays records according to their fill rate.
For instance, a vacancy can have no bookings or some bookings. If a vacancy has bookings, they can be in the form of 'active [1]', 'pending [0]'. The query I…
I have to print out only the publishers that published more than 2 books, but for my results, I always get
PUB_NAME |TOTAL
--------------------------------
Abatis Publishers |4
Core Dump Books |1 <------don't…
I have a column that its value is set from enum.
I would like to check if there are lines that mistakely were set to a value nor from the enum, grouped by their value.
The following queries retrive the same results:
Using HAVING
select COLUMN1,…
I understand the distinction between WHERE and HAVING in a SQL query, but I don't see why they are separate clauses. Couldn't they be combined into a single clause that could handle both aggregated and non-aggregated data?
I am trying to figure out how to filter a data set from SQL Server.
DECLARE @OUTPUT AS TABLE (FILTER INT,PART INT,LOT INT)
INSERT INTO @OUTPUT (FILTER,PART,LOT)…
I'm learning SQL through GALAXQL http://sol.gfxile.net/galaxql.html
Im on lesson 17 - GROUP BY/HAVING
Here is the scenario:
Let's look at couple of SELECT operations we haven't covered yet,
namely GROUP BY and HAVING.
The syntax for these…
Is there a way to write a parametric SQL query that matches notes linked to multiple projects without using HAVING ?
SQLfiddle
Say I have a "notes" table, a "projects" table and a "notes_projects" table linking these two together. I want to find the…
I'm having a unexpected problem to perform a query using QueryDsl/Hibernate (2.8.2).
My field is generated like this, as you can see, it's an Integer.
public final NumberPath nbPotatoes= createNumber("nbPotatoes", Integer.class);
I'm trying to add…
I am trying to find products that have certain specs. Because of the complex combinations of specs I have another table that is a n:m relation to another table.
product
id | other data ...
---+---------------
1 | bike
2 | bus
3 |…