cross-join

Crossjoin using QueryOver

半腔热情 提交于 2019-12-01 01:37:09
How could I replace the HQL query below using QueryOver API? var sql = "from Role r, Action a where r.Active = :active and a.Active = :active"; var result = manager.Session.GetISession().CreateQuery(sql) .SetBoolean("active", true).List(); I don't believe there's a way to do this in QueryOver, since both JoinAlias and JoinQueryOver require an expression describing a path to the related entity. However, this is easy to accomplish in LINQ-to-NHibernate: var result = (from role in manager.Session.GetISession().Query<Role>() from action in manager.Session.GetISession().Query<Action>() where role

error : subquery must return only one column

孤街浪徒 提交于 2019-11-30 22:59:55
问题 I am getting the error subquery must return only one column when I try to run the following query: SELECT mat.mat as mat1, sum(stx.total ) as sumtotal1, ( SELECT mat.mat as mat, sum(stx.total) as sumtotal FROM stx LEFT JOIN mat ON stx.matid = mat.matid LEFT JOIN sale ON stx.saleid = sale.id WHERE stx.date BETWEEN '2013-05-01' AND '2013-08-31' AND sale.userid LIKE 'A%' GROUP BY mat.mat ) AS MyField FROM stx LEFT JOIN mat ON stx.matid = mat.matid LEFT JOIN sale ON stx.saleid = sale.id WHERE stx

Crossjoin using QueryOver

老子叫甜甜 提交于 2019-11-30 19:32:41
问题 How could I replace the HQL query below using QueryOver API? var sql = "from Role r, Action a where r.Active = :active and a.Active = :active"; var result = manager.Session.GetISession().CreateQuery(sql) .SetBoolean("active", true).List(); 回答1: I don't believe there's a way to do this in QueryOver, since both JoinAlias and JoinQueryOver require an expression describing a path to the related entity. However, this is easy to accomplish in LINQ-to-NHibernate: var result = (from role in manager

Optimize Spark job that has to calculate each to each entry similarity and output top N similar items for each

纵然是瞬间 提交于 2019-11-28 08:46:11
I have a Spark job that needs to compute movie content-based similarities. There are 46k movies. Each movie is represented by a set of SparseVectors (each vector is a feature vector for one of the movie's fields such as Title, Plot, Genres, Actors, etc.). For Actors and Genres, for example, the vector shows whether a given actor is present (1) or absent (0) in the movie. The task is to find top 10 similar movies for each movie. I managed to write a script in Scala that performs all those computations and does the job. It works for smaller sets of movies such as 1000 movies but not for the

sql cross join - what use has anyone found for it? [closed]

断了今生、忘了曾经 提交于 2019-11-28 07:42:28
Today, for the first time in 10 years of development with sql server I used a cross join in a production query. I needed to pad a result set to a report and found that a cross join between two tables with a creative where clause was a good solution. I was wondering what use has anyone found in production code for the cross join? Update: the code posted by Tony Andrews is very close to what I used the cross join for. Believe me, I understand the implications of using a cross join and would not do so lightly. I was excited to have finally used it (I'm such a nerd) - sort of like the time I first

Mixing implicit and explicit JOINs

半城伤御伤魂 提交于 2019-11-27 14:49:02
I am having a problem with Hibernate generating invalid SQL. Specifically, mixing and matching implicit and explicit joins. This seems to be an open bug . However, I'm not sure why this is invalid SQL. I have come up with a small toy example that generates the same syntax exception. Schema CREATE TABLE Employee ( employeeID INT, name VARCHAR(255), managerEmployeeID INT ) Data INSERT INTO Employee (employeeID, name) VALUES (1, 'Gary') INSERT INTO Employee (employeeID, name, managerEmployeeID) VALUES (2, 'Bob', 1) Working SQL Both of these queries work. I realize there is a Cartesian product;

combinations (not permutations) from cross join in sql

谁说胖子不能爱 提交于 2019-11-27 08:54:04
If I have a table that I'd like to cross join to itself, how can I remove the duplicate rows? Or to put it another way, how can I do a "order doesn't matter" cross join? So for example, if I have a table T: field | ------- A | B | C | and I cross join to itself so that i don't get the A | A rows T as t1 cross join T as t2 on t1.field != t2.field I would get the following: field | field ------+------- A | B A | C B | A B | C C | A C | B However, to me A, B is the same as B, A. Is there a good way to remove these duplicates? In other words, I want the combinations not the permutations. T as t1

SQL Server: What is the difference between CROSS JOIN and FULL OUTER JOIN?

戏子无情 提交于 2019-11-27 02:54:41
What is the difference between CROSS JOIN and FULL OUTER JOIN in SQL Server? Are they the same, or not? Please explain. When would one use either of these? A cross join produces a cartesian product between the two tables, returning all possible combinations of all rows. It has no on clause because you're just joining everything to everything. A full outer join is a combination of a left outer and right outer join. It returns all rows in both tables that match the query's where clause, and in cases where the on condition can't be satisfied for those rows it puts null values in for the

Optimize Spark job that has to calculate each to each entry similarity and output top N similar items for each

亡梦爱人 提交于 2019-11-27 02:25:27
问题 I have a Spark job that needs to compute movie content-based similarities. There are 46k movies. Each movie is represented by a set of SparseVectors (each vector is a feature vector for one of the movie's fields such as Title, Plot, Genres, Actors, etc.). For Actors and Genres, for example, the vector shows whether a given actor is present (1) or absent (0) in the movie. The task is to find top 10 similar movies for each movie. I managed to write a script in Scala that performs all those

sql cross join - what use has anyone found for it? [closed]

末鹿安然 提交于 2019-11-27 01:56:57
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . Today, for the first time in 10 years of development with sql server I used a cross join in a production query. I needed to pad a result set to a report and found that a cross join between two tables with a creative where clause was a good solution. I was wondering what use has