Skip to content

How to count all distinct rows?

If I have a table like below, how can I count and sum all distinct values? student_name | section | score | class ————-|———|——-|——- John | B | 32 | 8 Doe …

SQL If else statement dealing with current time

I have this SQL that pulls exactly what I want, but I am missing the last piece. I need the SQL only to display information when the HRS is greater than 48hrs. I tried doing an if else statement but I …

Division by 0 in SQL Server

How to solve divide by zero problem? I am trying to calculate profit percentage but getting divide by zero error. I am new and tried all most all forum but couldn’t find any solution. I’m using SQL …

Balancing an environment monitor using SQL

I am working on something very specific so I’m hoping others have an idea of what approach might work. I’m trying to make it so a monitoring script that runs once every 5 minutes will not blast …

Querying a Many-to-Many Linking Table

I have a linking table for a many-to-many relationship, with the fields – idNote idTag I would like to filter for all the tags that are associated with the notes that contain a specified number of …