subquery

Calculate the true range using SQL Server 2014

天大地大妈咪最大 提交于 2019-12-11 12:14:12
问题 I am trying to calculate the true range from the table below. TIME BID-OPEN BID-HIGH BID-LOW BID-CLOSE 1993-05-09 21:00:00.000 1.5786 1.5786 1.5311 1.5346 1993-05-10 21:00:00.000 1.5346 1.5551 1.5326 1.5391 1993-05-11 21:00:00.000 1.5391 1.5521 1.5299 1.5306 1993-05-12 21:00:00.000 1.5306 1.5451 1.5106 1.5256 1993-05-13 21:00:00.000 1.5256 1.5416 1.5211 1.5361 So far I have managed to do this: SELECT t.Time, Round([BID-HIGH]-[BID-LOW],5) AS [H-L], Abs(Round([BID-HIGH]-[prev_BID-CLOSE],5)) AS

jpa eclipselink subquery in from clause

放肆的年华 提交于 2019-12-11 12:03:24
问题 I read here https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/JPQL#Sub-selects_in_FROM_clause that eclipselink support subquery in from clause but when i'm using this query queryString2="SELECT NEW dz.com.naftal.erp.domain.view.MouvementProduitView('VAR',t.cds,SUM(t.mntttc)) " + "FROM (SELECT DISTINCT m.mouvementProduitViewPK.cds as cds,m.mouvementProduitViewPK.referenceDocument,m.mouvementProduitViewPK.typeDocument " + "m.mntttc as mntttc FROM

Mysql subquery help

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 11:58:49
问题 I have a table which had two types of records - update and end (EventType - Column). The Update record has the PID and webpage details where as the end record has the volume (upload and download) and PID detail (no web page detail:(). The common field for the both of the record types are PID. Now from the table, I need to get the SUM(ULVolume+DLVolume) for all of the websites i.e - get sum(ULVo+DLVol) of each (get PID of each (get distinct websites)) At the end, this is what i am looking for

subquery with join in laravel

可紊 提交于 2019-12-11 11:41:48
问题 I'm about to go crazy about a query, can someone help me to translate a query to work in laravel, or to write in "laravel way". The query code is below, and it's using MySQL. The part that I'm stuck is in the first JOIN with the subquery to the other JOIN it. SELECT usr.token, usr.id, usr.username, usr.sn, usr.givenname, usr.telefone_numero, usr.active, usr.unidade_id, usr.divisao_id, usr.secao_id, clients.nick, posto_grad.sigla AS quadro_sigla, log_logradouro_complemento, log_logr.nome AS

MYSQL optimize & questions

£可爱£侵袭症+ 提交于 2019-12-11 11:30:08
问题 I am trying to optimize my MySQL queries and I need some help. Here is my current query : SELECT *, (SELECT name FROM stores WHERE id = products.store_id) AS store_name, (SELECT username FROM stores WHERE id = products.store_id) AS store_username, (SELECT region_id FROM stores WHERE id = products.store_id) AS region_id, (SELECT city_id FROM stores WHERE id = products.store_id) AS city_id, (SELECT name FROM categories_sub WHERE id = products.subcategory_id) AS subcategory_name, (SELECT name

Hibernate NOT IN subquery

自古美人都是妖i 提交于 2019-12-11 11:27:42
问题 I have Rooms with a Many-To-Many relationship to SeminarLectures. I want to get all Rooms that have no lecture at a given date. Why is this hibernate query not working? SELECT r FROM Room as r WHERE r NOT IN (SELECT DISTINCT ls.rooms FROM SeminarLecture AS ls WHERE ls.date <> :date) I get: Syntax Error in ...; expected "*, NOT, EXISTS, INTERSECTS, SELECT, FROM" 回答1: As documented here: 16.13. Subqueries For databases that support subselects, Hibernate supports subqueries within queries. A

UPDATE table using a subquery in SQLite

笑着哭i 提交于 2019-12-11 10:27:00
问题 I want to update records from a sub-query. I am using the following query: UPDATE table1 SET a = aa FROM (SELECT a AS aa FROM table2) AS abc WHERE f = 1 This works fine in SQL Server. But doesn't work in SQLite. Any Idea? 回答1: SQLite does not support UPDATE ... FROM . See https://www.sqlite.org/lang_update.html 来源: https://stackoverflow.com/questions/11825667/update-table-using-a-subquery-in-sqlite

Dynamic linq-to-nhibernate query problem

六月ゝ 毕业季﹏ 提交于 2019-12-11 10:23:19
问题 Suppose I have classes Foo and Bar as follow: public class Foo { public string F1 {set; get;} public string F2 {set; get;} public Bar ContainerBar {set; get;} } public class Bar { public string B1 {set; get;} public string B2 {set; get;} public List<Foo> Foos {set; get;} } Following linq query has errors saying that foo does not contain a property named F1 . var query = from foo in session.Linq<Foo>() select foo.ContainerBar; query = query.Where(foo => foo.F1 == "abcdef"); I know foo in

Oracle --> Postgres query

眉间皱痕 提交于 2019-12-11 10:17:18
问题 I'm an Oracle guy trying to convert a query like this to Postgres. Not really understanding all the syntax, etc. Was hoping someone can help? Oracle Query: SELECT c.code, c.recommendation, s.suggested, s.sugg_by, a.approved, a.app_by FROM (SELECT code, recommendation FROM recommendations) c, (SELECT code, suggested, sugg_by FROM suggestions) s, (SELECT code, approved, app_by FROM suggestions) a WHERE c.code = s.code(+) AND c.code = a.code(+); Much appreciated 回答1: You can try to use OUTER

To subselect or not to subselect?

流过昼夜 提交于 2019-12-11 10:07:16
问题 I start to get familiarized with subselects, but ATM I'm just scratching my head why MySQL kicks himself in the groin with the following: SELECT id_topic, id_member_comment, pd.username, dt_post FROM forum_comment c LEFT JOIN persondata pd ON c.id_member_comment = pd.id_member WHERE id_comment IN ( SELECT MAX(last_id_comment) AS id_comment FROM forum_topic GROUP BY cat_id ); If I run the query SELECT MAX(last_id_comment) AS id_comment FROM forum_topic GROUP BY cat_id separately and substitute