I want to both group some rows together but return 1 column of the individual rows from the group onto the same line as well, probably easiest to show with an example…. Original Data Grouped by rDate, track, AVG(odds) Desired output, grouped with average odds but with individual odds added to grouped ro…
Tag: sql
SQL Comparison Operator Issue) …right syntax to use near ‘>’2021-06-01’ AND 100*(d1_close-close)/close>’29” at line 1″)
I’m trying to run a SQL query through python file, and I’m getting the error message My query code is as below: I have also tried different versions like below: UPDATE)) I think the syntax error is in the comparison operator. How can I send comparison operator from python to SQL? Answer Triple quo…
SQL – How to find if the combination of column has occured before or not?
Following example demonstrates the question id location dt 1 India 2020-01-01 2 Usa 2020-02-01 1 Usa 2020-03-01 3 China 2020-04-01 1 India 2020-05-01 2 France 2020-06-01 1 India 2020-07-01 2 Usa 2020-08-01 This table is sorted by date. I want to create another column, which would tell if the id has been to th…
How to get JSONB array index
I’m sure there’s a simple answer to this but I just can’t find it. I need to obtain JSON array elements as rows, but their index is relevant for the subsequent processing. Here’s a [very simplified] example: I need to get: I’ve tried: But the section column is not computed correc…
Can’t found the poroblem within this Hive Query [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed las…
MySQL column to show the sum of column in another table
I have two tables in SQL both hold the ID of users. Table Accounts Table Transactions The table accounts column points should have the sum of that ID in table transactions. So in table one, the output should be points of ID 1 to be 5 and id 2 to be 20. I am new to MySQL so if you
SQL query to add column values
TABLE T1 Name ID AMAN 10 JIM 11 SAM 12 TABLE T2 VAL ID A00 10 B0 11 The result I want: T3 Name ID VAL AMAN 10 A00 JIM 11 B0 SAM 12 NA How can I write this query? Answer
How to add a minutes column to date column sql
I may sound silly asking it – but I have the need to add a value derived from one column of database to the other which is the date. Following is the image of data I have – timeelapsed/60000 gives me the duration of task in minutes and I would require the same to be deducted from the lastupdatedti…
Finding out information from two tables – SQL
everyone! I’m at the point of my SQL learning where I’m having a hard time trying to search to explain what I’m trying to do with SQL but here’s what I got. I have two tables. Let’s call the first one: And the second one: What I’m trying to do is get all account names and t…
Error when SQL Server grand total comes out on first row instead of at table end
The following query gets row and column totals. When I add ORDER BY, the column total appears in the first row instead of the bottom row. What could be your suggested solution? Answer you can use grouping which returns 1 if the column is part of aggregation and you can use it in your order by: