Skip to content

SQL Pivot on Conditional Count

I have a table of vulnerabilities using SQL server, when I perform the following query select * from table The output looks like so. | Name | HostName | Week | | ————- |——-…

sql query to count and display full name

So I am very confused by this query to display teachers’ full name. I have used teacher_name ||’ ‘|| teacher_lastname, but when I try to do so for the students, something happens. I am trying to get …

Ignoring duplicates based on a criteria except one

I have a table in ms access that gets updated daily. I need to remove all the duplicates posted within the same start date based on Policy number except to keep only 1 record with the highest number …

Select from a table and count from another

i have two tables, one for authors the other for books, i want to count the number of books per author Table authors +—-+——————-+ |id | name | +—-+——————-+ |…

Divison and subquery in select

I want to divide the total of accounts from ‘ed’ table against the ‘e’ table and I am getting a zero, Table ‘ed’ has 16784 accounts and ‘e’ table has 41601 accounts so I want to divide 16784/41601 but …

Sqlite select column contains each of ids

I have a table CREATE TABLE humans_to_pets ( human_id INT NOT NULL, pet_id INT NOT NULL ) where I am storing pairs what human own what pet (many to many). Given list …

Update Statement Sql Access Double Inner join

I have the following command UPDATE tbl1 SET tbl1.val = 7 FROM ((tbl3 INNER JOIN tbl2 ON tbl3.ID = tbl2.ID) INNER JOIN tbl1 ON tbl1.ID = tbl2.ID) WHERE tbl3.ID = 2 AND tbl1.val = [val]; The …