Skip to content

SQL GROUP BY columns with inverted values

Suppose I’ve a table with like this: Where G1, G3 are VARCHAR and G2, G4 are INT If I do a simple GROUP BY on G1..G4 I get: I’m wondering if is possible to aggregate on inverted value G1,G2 <-> G3,G4. What I want to achieve is a result like this: What I tried is to get the inverted rows,

Make custom Restriction NHibernate for QueryOver

I’m stuck in a simple problem, I’d like to add a new custom restriction in NHibernate. I want to write a simple QueryOver with a fulltext index, an example with a Projections is here How to use Full Text Search for any property with QueryOver API But I need a more flexibility so I’d like som…

SQL query: Extra line with no data

I´m trying to get the first 10 records when concatenating two strings, counting the number of records for these, and getting the average duration of the trips. The query jeeps showin the first line of the results with no data (maintaining the “to” in the route column, and null duration) what it af…

Variable in dateadd function snowflake

I have a query like this: It gives this error: Single row subquery returns more than one row. Is there a way to pass a variable in the 3rd argument of dateadd function? Because my cte will return many min_date based on the group by clause. TIA Answer Yes, sub-select in SELECT need to only return one row, you …