I need to retrieve the total sum of all rows from this view, if I group by orderid the sum function works but then I lose each product row from the view and I don’t want that in this case. Is there a …
Tag: sql
inserting into table with conditions
SQL. i have two tables residents (primary key rid) and dependents (primary key did). dependents is connected to residents through rid. I want to insert rows into dependents table only if the rid in the insert statement matches with any of the rid in the residents table. i tried the code below, but there is so…
Stored Procedure return default value?
in my database, there is a Stored Procedure with INSERT INTO statement. The problem is I want this stored procedure will return the StudentCode default value, I think it’s impossible to use the SELECT …
How to cast from double to int in from_json Spark SQL (NULL output)
I have a table with a JSON string When running this Spark SQL query: select from_json(‘[{“column_1″:”hola”, “some_number”:1.0}]’, ‘array’) I …
SQL SERVER JOIN ID rows from one SELECT query to second SELECT query
Our fleet drivers accumulate hours in each type of rig that we operate. This first query returns a list of driver IDs for a given route. Result: I need to feed these IDs into this second query, which returns the number of accumulated hours for a given Driver ID. I’m trying to achieve: EDIT: For clarific…
Last_Value returning the current value
I am not able to get the last value, rather it is just returning the same value with my code below in snowflake – does anyone have any idea? Is there something glaring wrong? select MNTH, …
SQL Pivot of string
i have the following data in SQL 2017 Number Description Value 37 Recorded 2019-11-06T10:51:25.482-05:00 37 ICD10Code Z32.00 37 ICD10Desc Encounter 37 Status …
How do I get all timestamps associated with an ID and aggregate it them into total time elapsed?
I have a sample table: id timestamp 1 2020-02-03T19:25:41.961Z 1 2020-02-03T19:25:42.000Z 1 2020-02-03T19:26:33.147Z 2 2020-02-03T20:21:29.684Z 2 2020-02-03T20:21:29.705Z …
issue with INNER JOIN in MYSQL 6.3
im trying to join data from two tables like this: Select portt.nameport, tool.weapen From Portt Where portt.toolsum – ( select count(*) From tool …
Many-to-many sql select query containing multiple values, all values are taken into account
There is the following database structure: How do I write a query that returns only those Questions that have both CSS and JS tags?