I have a string of numbers like this: I want to add up these numbers which in the above example would result in 14: 6+7+0+…+1+0+…+0+0+0=14 How would I do this in BigQuery? Answer Consider below approach with output
Tag: sql
Why does this SQL query get stuck in an endless loop?
The following PostgreSQL query gets stuck loading endlessly. I know correlated sub-queries can take long, but a SELECT using the same parameters worked quickly and returned the desired results. And I have a small data set that I let run for an entire day just to make sure it wouldn’t eventually work wit…
PLS-00201: identifier ‘COL1.POTO’ must be declared
Hi I have problem with variable: Here is my code The Osoba table: It’s my first post so don’t be so angry for formatting. Answer This can be done with a single efficient SQL statement. I highly doubt that the SELET statement and the general logic in your code is correct. CROSS JOINs create a carte…
Tricky MySQL view
I am finding it very difficult to create a view in MySQL, and hope someone could help me out. This is the schema of my db: This database collects a series of football games and many characteristics for each one, as well as all the teams and the seasons. Thanks to this view (https://stackoverflow.com/a/7079444…
Extracting hashtags by sql
I have this problem – currently I am extracting hashtags in a C# application but now I want to move it to SQL Server. In C# I have code using a regex: In T-SQL, I would like to have something like this: Answer Using the string_split
How can I extend an SQL query in a variable?
I am testing possible SQL injections on my DB, and I am running a simple function to get results which a user should not be getting. The return value is correct based on id, however, the rest of the query is completely being ignored. I want to return all the data from the data table. Is there something wrong …
Combine Date and Time Fields and Order By DateTime Field
I would like to combine the date and time for meta values performance_date_1 and performance_time_1 and then sort by this new DATETIME value. Here is my SQL query so far, but no luck. Query SQL: SELECT TIMESTAMP(performance_date_1, performance_time_1) as DateTimeTS FROM test ORDER BY DateTimeTS; Because of ho…
MYSQL Query select only first record of foreign key
First of all, I am pretty new to MySQL. I am currently stuck with the following query. I have several tables that have relations between each other. Every user can create multiple projects. Every project can have one attachment, multiple attachments (images) or no attachment at all. Every project only has one…
How do combine two Queries or is it only one?
Question: How do combine two Queries or is it only one? Example: I have two exact similar tables my PostgreSQL Database. info_table and info_table_dump with the exact same columns date_at, name, color and length . Now i want to know if there are entries in info_table_dump that do not exist in info_table. Ther…
Missing query data when using Sum
My database in Microsoft Access looks like this: Every Client can have many assistants. Every Assistant may have one client or no clients at all. Assistant have a Nice field which is Boolean, indicating whether the Assistant is nice. I need a query where I can get all of the clients, together with a boolean v…