I have two tables, first table is:
docs
and another table:
doc_val
with doc_id as foreign key from table docs
I need to get list of docs (including val, type and criteria from doc_val ) which matches certain conditions, say for example:…
Dear fellow Stackoverflowers,
How may one select 2 different counts from the same table for scenarios:
x=a and x=b
specifically, (WHEN type = subdomain) AND (WHEN subtype = subdomain)?
to add them together to create a 'totalcount'?
My attempt (for…
I have the the following SQL statement:
SELECT [l.LeagueId] AS LeagueId, [l.LeagueName] AS NAME, [lp.PositionId]
FROM (Leagues l INNER JOIN
Lineups lp ON l.LeagueId = lp.LeagueId)
WHERE (lp.PositionId…
I'm a bit new to SQL;
I have a single table Products:
maker model type
A 1232 PC
A 1233 PC
A 1276 Printer
A 1298 Laptop
A 1401 Printer
A 1408 Printer
A 1752 Laptop
B 1121 PC
B 1750 Laptop
C 1321 …
In elasticsearch, how to achieve the function like this SQL:
SELECT a, sum(b), sum(c), d
FROM TableA
WHERE a IN (1,2,3,4) AND d = 88
GROUP BY a
HAVING sum(b) > 10
ORDER BY sum(b) desc, sum(c) asc
LIMIT 10 OFFSET 5;
So far I have only done this…
I been going thru some of the sql syntax to study for the oracle sql exam, I found something rather confusing
based on the official references, the select syntax is as follow :
SELECT
[ hint ]
[ { { DISTINCT | UNIQUE } | ALL } ]
…
I have a collection of objects containing transactional data. This dataset has a 3 level parent-child relationship with the levels being: Project > Stage > Transaction.
For each project and stage there will be multiple transactions.
class…
I have a table that stored users play list, a video can be viewed by multiple users for multiple times.
A records goes like this:
videoid, userid, time
123, abc , 2013-09-11
It means user(abc) has watched video(123) on 2013-09-11
Now I want…
I have two tables : dilemme and like. The first one contains articles and the second one contains votes. The script SELECT randomly one article to show and the user can vote (it's like and dislike).
I want to make a query that shows only the…
I have a table with transactions. Each transaction has a transaction ID, and accounting period (AP), and a posting value (PV), as well as other fields. Some of the IDs are duplicated, usually because the transaction was done in error. To give an…
Below is the table data (a small piece) basically I'm looking to query just the rows with the minimum original_date_ctr when grouped by the accoutn number.
I've tried using HAVING(MIN()), and where = Min() and other ways with no luck.
The correct…
My business partner and I are having issues selecting from a MySQL view that has a HAVING clause.
The query simply selects a few fields from the view, determines a distance dynamically with a few calculations, and aliases it as 'distance' - then…
I'm trying to select products based on facets for a product category page.
The basic structure is:
Product_Facets
--------------------------------
UID ProductID FacetID FacetOptionID
1 1 1 1
2…
A portion of my query looks like:
HAVING date > '2011-04-13 04:28:03'
The date variable is indexed, does this have any effect on the query?
EXPLAIN EXTENDED doesn't seem to be using the index, but I don't know if that's only because I have 4 rows…