I'm trying to run the following query in SQLite 3:
SELECT *,
DISTANCE(latitude, longitude, ?, ?) AS "distance"
FROM "country"
WHERE "id" NOT LIKE ?
HAVING "distance" <= ?
ORDER BY "distance" ASC;
But I get the following error:
SQLSTATE[HY000]:…
Using SQL Server 2005. I am building an inventory/purchasing program and I’m at the point where I need the user to “check out” equipment. When he selects a product, I need to query which stock locations have the available Qty, and tell the user…
I have this tables,
user
id
name
visit
id
id_user (fk user.id)
date
comment
If i execute this query,
SELECT u.id, u.name, e.id, e.date, e.comment
FROM user u
LEFT JOIN visit e ON e.id_user=u.id
I get,
1 Jhon 1 2013-12-01 '1st Comment'…
The following criteria query calculates the average of rating of different groups of products.
CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder();
CriteriaQuerycriteriaQuery=criteriaBuilder.createQuery(Tuple.class);
Metamodel…
My database teacher asked me to write (on Oracle Server) a query: select the groupid with the highest score average for year 2010
I wrote:
SELECT * FROM (
SELECT groupid, AVG(score) average FROM points
WHERE yr = 2010
AND score IS NOT…
Can anyone explain the differences between following two requests:
SET @foundnow=0;
SELECT id, (@foundnow:=IF(`id`=3,1,0)) as ff
FROM `sometable`
HAVING @foundnow=0
result is
id ff
1 0
2 0
3 1
and
SET…
I need a SQL function "having" in Magento. As far as I know, there is no having function.
So I try to implement it in collection class
public function addAttributeHaving($attribute)
{
$this->getSelect()->having($attribute);
return…
I want to search multi vars that could be true in WHERE condition or in HAVING condition in a group_concat table. Something like this:
SELECT
article.id,
article.name,
GROUP_CONCAT(tags.name order by tags.name) AS nameTags,
…
My query looks like this,
SELECT field1, field2, (SELECT TOP 1 field1 from table1) as field3
FROM table2
HAVING field3 > 0
it throws an error
invalid column name field3
I want to project the pid indexes for all products which have the same title, as I'm using the following as a sub query.
Product(pid, title)
SELECT p.title
FROM product p
group by title
HAVING ( COUNT(p.title) > 1 )
this outputs the duplicate…
I have a form that people can use to send emails to our clients. The user has an option to select between two canned messages (Message "1" or Message "2"). Behind the scenes, every time they hit the "SEND" button it logs into a "RECORDS" table (so…
I have been trying to convert a complex SELECT query to an UPDATE query, but I keep getting the 1064 syntax error.
The goal for the query is to update certain rows which meet particular conditions, however the joins and the GROUP BY and HAVING…
I looked at a similar question and read the documentation on the average function, but when I tried:
CREATE TABLE tab(
id INT,
score INT
);
INSERT INTO tab VALUES
(1, 22),
(2, 45),
(3, 82),
(4, 87);
SELECT score,AVG(score)
FROM tab
GROUP…
It's hard for me to summarize the query I want to make, so maybe an example will make it clearer.
Let's say I have two primary tables:
employees:
| employee_id | employee_name |
| ----------- | ------------- |
| 1 | Alice |
| 2 …