Skip to content

Tag: sql

Combine SQL rows into one column based off two other columns

I have this SQL statement: It returns a table like: But I am looking to have something like this: How do I change my SQL statement to accomplish this? Answer The solution to this problem ended up being to create a temp table for the main query. Then pulling the appropriate data out of the temp table utilizing…

MySQL Query Returns Different Results

I’m having a strange problem with the following query: Sometimes I get zero, one, two or three results. I should always get three results. What could be causing this? Answer As pointed out by Solarflare, GROUP_CONCAT() could produce your team string in a random order, e.g. ‘Van Williams & Dere…

Combine 2 sql queries in Bigquery

I currently have two queries that i’ve stitched together using views in Bigquery. I am wondering if there’s a way to combine them into a single query and eliminate the need for multiple views. The first query concatenates a few strings to create a field “id” The second query de-dupes t…

How to check for column attributes in postgreSQL?

I am new to SQL. Let say that when someone created a table like this in database named test1 of PostgreSQL: I make a query to the database and do not know how data in columns are stored. Is there a query to return the stored definition of the columns in the users table or a method to check this

Postgresql conditional script

I need to update the column (vendor_type) in the table depending on values in other columns. Table name = “vendor” Columns = “client_id”(varchar), “coach_id”(varchar), “exm_vendor”(boolean), “vendor_type”(varchar) And this is what I want to do with p…