Skip to content

Tag: sql

How can I replace empty value to null with SQL?

Let us say, I want to find the second highest salary. For that I use the following query. However, I want this to return null when the table only contains one entry, and therefore there is no 2nd highest salary. How can I do that? Answer Use your query with aggregation: The aggregate function max() will retur…

How to use the COUNT function

I’m trying to set up the best basketball team for fantasy basketball in the 2020-2021 season. I created a database for basketball player’s stats and imported a table that contains projections and draft rankings for this coming season. I’m focusing on players who play in the center position, …

2 column with 2 different condition in one table

is it possible to create a query that will output 2 column with 2 different WHERE clause this my ideal output: where count 1 is the result of the 1st WHERE clause. Which I already created. What I want is to have another column where in the value will be with different WHERE clause. here’s my query: with…

Oracle SQL Subquery – Usage of NOT EXISTS

I used a query to find a list of Primary Keys. One Primary key per each ForiegnKey in a table by using below query. Let us say this is the result : 1,4,5 NOw I have another table – Table B that has list of all Primary keys. It has 1,2,3,6,7,8,9 I want a write a query using the above

SQLite Incomplete Time String

I have a table with incomplete time strings, such as ‘0:09.735’ (minutes:seconds.milliseconds). As the function strftime expects certain formats, such as ‘%H:%M:%f’, I have “to complete” the incomplete timestring first. The first strftime function with the complete timestri…