Using the query below, I can search for properties within a given radius and results are returned.
SELECT id, address, ( 3959 * acos( cos( radians( 53.184815 ) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-3.025741) ) + sin(…
Urgh...my LINQ has suddenly taken a turn for the worse!!
I have two tables and want to join and perform aggregate functions upon the tables.
Firstly, is this possible, I am assuming it is, and secondly, how do I handle the aggregate functions? As…
I am using Microsoft SQL Server 2014.
The following is my query
SELECT type, SUM(calories) AS total_calories
FROM exercise_logs
GROUP BY type
HAVING total_calories > 150;
and I get the error
Msg 207, Level 16, State 1, Line 2
Invalid column name…
Problem
We have a Users table and a Addresses table.Each user can have multiple addresses. We have a bit field called IsDefault where a user can select their default address. This field currently isnt mandatory and possibly will be in the future, so…
I have 3 tables
Table 1.) Sale
Table 2.) ItemsSale
Table 3.) Items
Table 1 and 2 have ID in common and table 2 and 3 have ITEMS in common.
I'm having trouble with a query that I have made so far but can't seem to get it right.
I'm trying to select…
I need to use having clause in Magento custom collection grid, I try to do this:
$store = Mage::app()->getStore($this->getStore());
$collection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('sku')
…
Assuming a DB like this:
Date | Attribute1 | Attribute2 | ... | AttributeN
-------------------------------------------------
1 | A | C | ... | ...
1 | B | C | ... | ...
2 | A | A | ... |…
Maybe the title was not the best I could use to discribe the issue
an example of the table structure I am dealing with is in the image below. I need to write a query to pull all records for "Manufactures" that have more than one record. So the end…
The first two queries work fine, the 3rd one runs but brings back nothing when there should be results. How can I get the 3rd one to bring back results. It seems to me the GROUP BY and HAVING are not working together.
The 2nd query returns 32 Active…
I'm working on a query to return how many activists have volunteered this year by team more than once; I got it to work as a standalone query:
SELECT Activists.team, COUNT(id) AS Activists
FROM
(
SELECT e.id, v.team,
…
See the following SQL statement:
SELECT datediff("d", MAX(invoice.date), Now) As Date_Diff
, MAX(invoice.date) AS max_invoice_date
, customer.number AS customer_number
FROM invoice
INNER JOIN customer
ON…
I have manually built a large query using the various eloquent functions (i.e. $this->newQuery()->join....), but I can't get it to run.
When I call
echo $query->toSql();
It shows me the query. I can copy and paste it into my command line mysql…
I need to show how many different values every 'id' has.
It should look like this:
id | component_a | component_b | component_c
--------------------------------------------------
KLS11 | none | one | none
KLS12 | …
Consider two tables:
Foo:
id INT,
name VARCHAR
Bar:
id INT,
foo_id INT REFERENCES Foo(id),
event_type VARCHAR DEFAULT NULL,
event_duration INT DEFAULT NULL
Each Foo item can have multiple Bar events. How to query for Foo items which do…