Skip to content
Advertisement

How to get the count of 2 values in the same column, in the same table?

I have a dataset about chess games, and in the winner column there are only 2 values: ‘white’ and ‘black’. I want to show COUNT(winner) as WHITE_WINS and COUNT(winner) as BLACK_WINS. I tried inner joining the table by itself, however couldn’t get the correct SQL query to do the job. How can I get a table like: Answer Use conditional

Arranging data by year and proportion

I have one table with the following format: Note 1: [End_Date = NULL] means that participation has not ended. [Proportion = NULL] means that participation is 0. Output: I want to have the proportion of each sub_entity for every active year. Note 2: One Sub_Entity can be a proportion of different Entities. The final table will be something like: Note

Subtract one hour result

I am pulling live data from a db2 server, I am building a Power bi report that shows by time each transaction made. There is a time difference between our server location so the result is one hour …

SQL Server – restart running count on change

The schema Simplified, a sales table with non-unique sales IDs. Within each ID there will be a sale of an element S, which can be followed by a sale of up to two elements L linked to the element S. …

Advertisement