I’m really a newbie in sql and bigquery. In this case I use bigquery-public-data.san_francisco_bikeshare.bikeshare_trips dataset (image 1 and 2). I want to count total of subscirber_type, ‘Subscriber’ and ‘Customer’, and their average duration_sec. So the column I want to make it…
SQL copying data with new foreign keys
I have a very tricky problem here. I have two tables. One is dependent on another by foreign key. Table 1 Table1ID Instance ID ModifiedBy 1 1 yevhen 2 1 yevhen 3 1 yevhen Table 2 ID Instance ID Table1ID 1 1 1 2 1 2 3 1 3 These are taken as datasets for something named “Scenario”. When somebody
Merge two row in one from different table
Below is simple example, I need in one row display value from different table. eg. need resaults as: Answer With sample data you posted, that’s join with coalesce.
SQL DELETE FROM several tables
I have the following tables: dataset, links, files dataset has a field called tiComplete, if it is 0 then the record is incomplete, links and files both have a field “biDataset” that references the record in the dataset table. I’m trying to create a query that deletes all entries from datase…
Data from the table based on the received
Table Users: id, login, name, age Table views: id, date, user_id, post_id Table other: id, timeD (date), post_id What is already there: Result: date and user_id I need to add in request to display data about the user (login, name, age), the user id is optional and the timeD column Example: date timeD login na…
Getting values based on other column
I have the following data in SQL. Is there a way using SELECT QUERY that we can replace the NULL values in DATE column based on the REF values? Like replace the NULL values with the first available date for matching REF value, without making any change to the database. Expected Result Answer You can do it wit…
Get the first record from Table 2 where timestamp is greater than timestamp in Table 1
I have two tables. EVENT_NARATIVE EventNum SEQ Message Message_Time GRADE_HISTORY EventNum Grade GradeChangeTime The EVENT_NARATIVE Table has a lot of data (millions of rows) and each Event (EventNum) can have multiple EVENT_NARATIVE records. The GRADE_HISTORY table contains thousands of rows and each EVENT c…
Finding computed fields in Firebird 2.5
Computed fields are readonly. I need to find all such fields in specific table. This query solves this problem (returns info if column is computed or not): At least it looks like it solves it, but it seems that returned informations are incorrect. When RDB$UPDATE_FLAG is 0, its computed (readonly). But its 0 …
SQL Server syntax correction [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 9 months ago. Improve this question I am trying to create a SQL Server stored procedure but I am getting…
How to Query JSON Within A Database
I would like to query information from databases that were created in this format: index label key data 1 sneaker UPC {“size”: “value”, “color”: “value”, “location”: “shelf2”} 2 location shelf2 {“height”: “value”, “row”: “value”, “column”: “value”} Where a large portion of the data is in one cell stored in a …