I am attempting to write a query to audit a table of IP addresses against a table of overlapping net blocks. Individual net blocks can be marked active or inactive via a BOOLEAN. The audit query …
Tag: subquery
how to write group-by query SQL with quantity unit conversion?
Stock Product Quantity Unit ——————————- 001 5 box 001 10 bottle 001 60 gallon Conversion Unit1 Unit2 Rate ———————- …
How to do sub-string calculations in SQL?
I am working with a table full of customer online orders. Each order has a company code which can be either ’09’, ’07’, ’04’, ’03’, and ’01’. Each order has an order number that looks something like …
SQL count rows with same value in column and group by id?
i have a table like this: i wonder if its possible to count the rows with same value and group them by id , but every time the code will return count 1 if i group them by id and not by value wanted output: Answer You need to count the value of the column value for each id: See
Mysql unknown column in subquery works
There are three tables – mapping_hospital_procedure, master_hospital and master_procedure. master_hospital contains an id column to identify each hospital. master_procedure also contains an id …
Select Subquery Group By
I am having an issue with this simple query. I get the error “Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, , >= or when the subquery is …
Query to find the city name with longest and shortest length
I’ve written a query to return me the cities with the shortest and longest length strings in a MS SQL SERVER database. Select city, len(city) as l From Station Where len(city) in ((select max(len(…
Postgres where clause over two columns from subquery
Database: Postgres Table name: records Has 4 columns Year | Dept | Expense | Month So per year there can be up to one record for each month / per department. I have a sub-query which returns me …
SQLite – How to perform COUNT() with a WHERE condition?
I have a products table with these fields: _id, product_name, priority and shelf_id. And I have a shelves table with these fields: _id and shelf_name. Currently, I have this SQL which returns a resultset showing the name of each shelf along with the number of products within each shelf: What I am trying to achieve is the creation of an
How to count distinct records in Access table and display that value in Excel
I have a table in Access that I’m querying from Excel. I need help with the sql statement. First, I need to filter the table based on SampleType matched criteria indicated in the Where clause. There are only 3 options: “mel”, “col” or “ lun”. The ultimate goal is to pass the number of distinct records from the SampleID column