Skip to content

Tag: sql

MS-Access: Calculate Stock From 3 Tables

I was reading this post from StackOverFlow to adjust query to calculate stock from 3 tables. I have 3 tables tblItems, tblPurchase and tblSales. tblItems contains items information like below. Screenshots of my tables tblItems: tblPurchase: tblSales: And my expected result like below In query result items det…

Update table with using NEWID() function

In general, I would update a table randomly like the following scripts. However, I get some issue. It would update more/less then 2 rows. I try execute the following scripts many times for debug. The results are not always only two records. If I remove the order by newid(), the number of output result will be…

How do I find the 4th record in SQL/ SAS PROC SQL?

Initially I tried including a sample SAS Table here but I can’t get the script to line break where it should – Appreciate if you can let me know how to manually insert the line break when typing in the text editor, thanks My question: For SAS PROC SQL – How can I return the 4th highest recor…

Finding Similar People’s Names from Database

I have a table in MySql with names in it. I am trying to, given an input name, find all similar names in the table. I’ve heard a lot about Levenshtien/Damerau–Levenshtein distance, but it doesn’t seem like it would work well for this, I’ll explain my reasoning later. To elaborate: User input…

Get First Record of Each Group

First I would like to apologize if it is a basic question. So, i have monitoring data being stored every 5 seconds. I want create a query that returns me the first record every 10 minutes, for example:…

SQL group and summing at new row

I have an issue where I am trying to create a new “row” (not part of the database) where it only gives me the SUM of the “count” column. I am wondering if that is possible? I tried adding the SUM(count(cost) as “total product cost” OVER() AS Total_Count; but that just creat…