I’ve got a table with lat and lng coordnates, and need to add the distance into a new column called ‘distance’ in Bigquery. table start_lat end_lat start_lng end_lng 41.8964 41.9322 -87.661 -87.6586 41.9244 41.9306 -87.7154 -87.7238 41.903 41.8992 -87.6975 -87.6722 I haven’t a clue how to do it. I saw some examples, but simply couldn’t apply it into this case.
Tag: sql
Alter Table Foreign Key
I’m trying to add barista_grade_id to the baristas table as a foreign key and I’ve looked every where on what syntax to use and it seems to be unanimous that this is the correct way. I did it before this and it worked. but because of some mistakes I deleted it and redo it again, but for whatever reason it
Convert JSONB Keys to Columns
I have a user table users containing id , name and information of type jsonb User Table id name information 1001 Alice {“1″:”Google”,”2″:”1991-02-08″} 1002 Bob {“1″:”StackOverflow”,”3″:”www.google.com”} I have another Table having all the profile fields values named ProfileFields profilefieldid Value 1 Company 2 DateOfBirth 3 ProfileLink The information jsonb column can only have keys present in the ProfileField Table. You
Best way to get high value of partition from oracle database?
Best way to get high value of partition from oracle database? Answer “Best” is subjective but you can retrieve the high values by quering the data dictionary:
Inserting data into table with select
i`m trying to do something…. I have to insert some data in to a table but….. So here is where I end up… any suggestion… Answer You cannot refer to an alias in the SELECT or WHERE clauses of a sub-query where it is defined. Generate the data in a sub-query (or a sub-query factoring clause) and then refer to
How to add ‘all’ CASE when group by CASES in SQL
I have a query like this: Which gives the result: How can I add a row for ‘all’ requests in CASES? If we add a when sp.provider=’prv1′ with no more detailed condition then all cases become one ‘all’ case because and other cases are ignored. Answer You can’t do that inside the CASE, as it behaves like a series of
SQL Calculating Hourly Sales
I am trying to create a SQL report that shows hourly sales. This is from my POS system. There’s a built in table that has basically all the data I need, I’m just struggling to calculate the sum of a column if they are in the same hour. Table vRPTHourlySalesPerformance (stripped down to only show relevant info): dt_when create_hour_ordinal c_ticketitem_net_price
I get ER_PARSE_ERROR when trying to CREATE a TABLE with PRIMARY KEY and FOREIGN KEY
I’m learning SQL and from time to time I get this error: ER_PARSE_ERROR. For example: What I get wrong is the ‘);’ I tried to rewrite the code, and restart the PopSQL program but non of them worked… Answer remove set keyword :
How to return multiple rows in stored procedure?
I have a procedure that returns multiple rows, but separately. Please take a look at its result: I causes some issues when I want to fetch the result in the code (backend side). Now I want to create a temporary table and insert all rows inside it and then return that temp table as the result of the stored procedure.
Mysql JSON_OBJECT aggregate json objects to json array where id matches
As mentioned in the title, i’ve been trying to aggregate json objects to a json array where the id is the same. I’ve got a main table “kurs” that has a unique id and is connected to the table “kompetenz” over a link table. For each “kurs” there can be multiple “kompetenzen”. However after a few hours of trying i