I am trying to create a table where the code N09 is included, where a student was assigned a set of codes that contains N09, and "Status Complete" was yes. I wanted to use group_concat to see if each set contains N09. I saw a similar question to…
Is there a way to expand/get all the records of a GROUP BY and HAVING query?
For example,
SELECT Column1, Column2, Column3, Count(*) as Count FROM table_name
GROUP BY Column1, Column2, Column3
HAVING Count > '2'
Is there an easier way to get all…
I distinctly recall that T-SQL will never let you mix LAG and WHERE. For example,
SELECT FOO
WHERE LAG(BAR) OVER (ORDER BY DATE) > 7
will never work. T-SQL will not run it no matter what you do. But does T-SQL ever let you mix LAG with…
I have the tables:
Product(code (PK), pname, (....), sid (FK)),
Supplier(sid(PK), sname, (....))
The assignment is:
Find Suppliers that supply only one product. Display their name (sname) and product name (pname).
It seem to me like a GROUP BY…
When I use HAVING in my QoQ coldfusion, the query returned will have two extra column: "Column_7" and "Column_8"
The original resultat
And the resultat with two extra columns
Here is my code
var qEffectifTemp = queryExecute("
SELECT…
I apologize if this has been asked before, but I couldn't find an identical problem in StackOverflow.
I have a table named prices, like this, where type, subtype and date are primary keys:
type subtype date price
18 | DFY | 2019-06-27…
I am trying to figure out how to query a table (the table is actually a result set, so it will be a subquery), group it by ColA=ColB (see below), and create a calculated field all in one step.
So, if my test data looks like
ColA ColB ColC
1…
i try to run a query with having:
SELECT
`doctors`.*,
(
SELECT GROUP_CONCAT(`areas`.`areaName` SEPARATOR ', ')
FROM `areas_has_doctors`
INNER JOIN `areas` ON…
I solemnly swear I did my best to find an existing question, may I'm not sure how to phrase it correctly.
I would like to return records for users that have quota for only one product type.
| user_id | product |
| 1 | A |
| 1 | …
l'll explain the use-case simply with following scenario.
Basically,i want to find all the pts/s from pts_table which contains all the orders of the pl001
pl_table
========
pl_id | order_id
pl001 order001
pts_table
…
What I'm trying to do is very similar to Select first row in each GROUP BY group?
but other than select first row after ORDER BY number DESC, I want to select a row shows up multiple times in database (has changed name in past) AND empty field…
I try to select only dog with weight superior to the average weight of all dogs.
I have this SQL query:
SELECT nameAni, weigth
FROM Animal
WHERE idTpAni IN (SELECT idTpAni
FROM TypeAnimal
WHERE libTpAni = 'DOG')
GROUP BY…
I posted on here last night looking for help with some homework. I'm down to my last question.
Here's the relevant piece of the schema I am working with:
CREATE TABLE votesOnPoll(
user_id int,
poll_id int,
option_id int,
voteDate date,
…
I have an SQL database with one table: Product (maker, type, model)
For each row we have a different maker (brand), a type of product(pc, tablet, laptop, etc.) and a model (1.1 / 2.0 / 3.4.5 etc)
Q: How do I get the makers who produce only one…