Expected results: Explanation: In the results, James is representing all people aged 20. And Blue is representing all people aged 15. And so on.. Question: How can this query type of query be achieved? Thank you. Answer If you want one name per age, you can use: If you want the first row, then:
Tag: sql
Calculate sum of price from 2 table sql server
After asking about calculate the sum of the total price here and Its work but then went I add(SUM(PRICE*AMOUNT) AS TOTAL_PRICE) to create my own View, the Total_price = Expr1, It just PRICE * AMOUNT, there is no sum here. I apply It to create a view here is the query Here is the output Could anyone help me ou…
Best practice for verifying correctness of data in MS SQL
We have multiple tables with different data (for example masses, heights, widths, …) that needs to be verified by employees. To keep track of already verified data, we are thinking about designing a following table: This table links the different product id’s, tables and columns that will be verif…
SQL Query to display dates weekly from current date
I have a requirement to display dates every week starting from current date for 48 months. I was wondering if it is possible through SQL or i will have to write a function to achieve it. Below is my …
Counting entries in SQL which meet a selective criteria
I have a tables which stores the type of account users create for a product. There are 3 possible paths. They can either create a trial account, then create a full account. They can create a full …
Finding the person with highest salary on mysql sample database
I have this mysql sample database (https://dev.mysql.com/doc/employee/en/sakila-structure.html). The question is i need to find top10 persons with highest salaries on the database. So far ive tried …
VBA 3131 error in SQL using variables in query
Can you please help me? I was trying to figure it out for about 2 hours but I still have some error in the syntax. I have the following code with String variables which I need to pass into the SQL …
Date conversion in SQL from 10-09-2020 to 2020-09-10
I want to convert it for comparing data & here I am stuck. I have data in date column like 10-09-2020 where convert(varchar, date, 111) >= ‘2020-09-10’ AND convert(varchar, date, 111)
Forcing NULL entries in ACCESS queries
I have two ACCESS tables as follows CustId CustType 1 Silver 2 Gold 3 Gold xDate CustId Value 01/01/2020 2 100 01/01/2020 1 50 02/02/2020 2 100 03/01/2020 2 …
Mysql subtract and sum
I have a below table in mysql. DROP TABLE IF EXISTS `mdc_data`; CREATE TABLE `mdc_data` ( `id` int(11) NOT NULL AUTO_INCREMENT, `tariff_id` int(11) DEFAULT NULL, `msn` varchar(100) DEFAULT NULL, `…