Skip to content

Tag: sql

GROUP BY within functions

I’m currently stuck with MySQL I would love to make this SQL to use the COUNT for each id_customer that was GROUP BYed as well. Picture of result And now it takes COUNT for every id_customer so it divides everything by 6 instead of 3 for id_customer 3, 2 for id_customer 1 and 1 for id_customer 66. Help …

How to change arrays into rows

There is a table in BigQuery that contains 2 REPEATED(arrays) type of columns, enterded_date and status. Table in BigQuery: Is it possible to make a query that returns rows instead? Like this: Answer Consider below approach if applied to sample data in your question – output is

How to move ID of duplicate names to a separate column

I have a MySQL table with two duplicate names, how can I separate the IDs of the duplicate names into a separate column? For example, like this: This is my current SQL statement to retrieve the current results in the first table: There is only one duplicate at most for each name. Thanks Answer If you are sure…

update rows using inner join posgresql

I have 2 tables users and countries, and i’m trying to set the country.name with users.country_name for all countries with null name. Schema : Ref: U.country_code > countries.code QUERY Error : DBSQLException: SQL Error [42P01] Answer Follow the correct update join syntax and also remove the alias fr…

Why is the return type of sysdate DATE? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 9 months ago. Improve this question Sysdate returns the current system date and time and its return type…