Skip to content

Tag: sql-server

Calculating percentages in SQL query

I have a table in SQL that has two columns of data, first is a week number, second is a value. There can be multiple records for the same week. Here’s some sample data (I added some SQL for this data at the end): id WeekNo MyAmount 1 1 5200.00 2 1 180.00 3 1 100.00 4 2 100.00 5

Why does this query return all the rows?

I have the following code: I want to get all the students who have a min grade 6, and I need to do it in subquery in where (most wanted to do it with exists, but not obligatory). My query right now returns all the students, however subquery gets not all of them. Answer If just one grade satisfies the

Passing parameters for a constraint function

I have the following table that joins driver and truck tables in order to assign trucks to drivers. I need to constraint entries that belong to the same driver on the same day, and DO NOT include the same truck code. It was suggested to create a boolean function to pass along dateval, truckval and driverval, …