[Solved] Mysql: How do I subtract a percentage from a number
Try this: SELECT amount – (amount * discount_percentage / 100) FROM tableA; 0 solved Mysql: How do I subtract a percentage from a number
Try this: SELECT amount – (amount * discount_percentage / 100) FROM tableA; 0 solved Mysql: How do I subtract a percentage from a number
Introduction Mysql is a powerful database management system that can be used to perform a variety of operations. One of the most common operations is subtracting a percentage from a number. This can be done using the MySQL SUBSTRING function. In this article, we will discuss how to use the SUBSTRING function to subtract a … Read more
Your SQL CTE syntax is incorrect: you have a comma after the last CTE’s close-paren. The only time you need a comma there is if you have another CTE following it. Try changing to with unit as ( select t.RefDate, … ), — yes comma here, between CTEs agg as ( select u.RefDate, … ) … Read more
First, let’s define what we need. We need a table (view) with these fields: ProductId, ProductName, ProductViewCount, and RootCategoryId. Imagine, the Category table has RootCategoryId field already. Then we can use this query to receive the result: SELECT P.Id AS ‘ProductId’, P.Name AS ‘ProductName’, PVC.ProductViewCount, C.RootCategoryId FROM Category C INNER JOIN ProductCategory PC ON PC.CategoryId … Read more
This is one of the simplest types of SQL queries. SELECT user_id FROM yourTable WHERE user_name=”UserA” The first line says which columns you want to return in the result. The second line identifies the table you want to get the columns from. The third line specifies conditions on the rows you want to use from … Read more
If you just want to return the rows from each table that match, then you can use a UNION ALL: SELECT * FROM Table1 WHERE column2 = 1 union all SELECT * FROM Table2 WHERE column22= 1; See SQL Fiddle with Demo If you want to return the rows that match both criteria, then possibly … Read more
Here is a function that works fine for all cases and return the list of all first candidates encountered if no choice can be made to separate them. def find_best(list_of_lists): i = 0 while len(list_of_lists[i]) == 0: i+=1 list_containing_candidates = list_of_lists[i][:] if len(list_containing_candidates) == 1 : return list_containing_candidates[0] else: if i+1 < len(list_of_lists): for next_list … Read more
When I need a list of integers I use SELECT help_keyword_id num FROM mysql.help_keyword HAVING num BETWEEN 1 AND 100 ORDER BY 1; solved SELECT mysql query to get first 100 numbers (1-100) [closed]
Is this what you need? select { border: 0 none; color: black; background: transparent; font-size: 14px; padding: 6px; width: 100%; background: #58B14C; text-indent: 50%; } #mainselection { overflow: hidden; width: 100%; background: #4CAF50; text-align: center; } select:hover { text-shadow: 1px 1px red; box-shadow:1px 1px red; } <div id=”mainselection”> <select> <option>Select options</option> <option>1</option> <option>2</option> </select> </div> … Read more
There’s two ways to do this: (1) a session, and (2) a form. A session is used to store values between page requests – it uses a cookie to identify your browser, which PHP manages for you. Your category could be set into a variable, and then re-read at page load. The other approach is … Read more
You can use the MAX() and MIN() function to get the ids having largest and the id having smallest discount. Select id,discount from customer where discount=(select MAX(discount) from customer) OR discount=(select MIN(discount) from customer); 3 solved select id by the min and max (sql) [closed]
You can take advantage of SQL Server’s flexibility to recognize various date formats. If you have the right regional settings, this should just work: cast(mycol as date) This gives you back a value of date datetype that corresponds to the input string; Demo on DB Fiddle: select cast(‘Jan 18 2019 12:00AM’ as date) | (No … Read more
SELECT * FROM student_certificates GROUP BY student_id HAVING COUNT([DISTINCT] certificate_id) >= 20 Join students table if some columns from it needed (do not forget to expand GROUP BY expression accordingly). 1 solved sql get query to get any student records who have passed multiple certificates? [closed]
I assume YEAR is an Integer number, best practice would be to have a column type as data, and get the year using the YEAR function in SQL. SELECT CONSUMER_NUMBER FROM CONSUMER_INFO WHERE YEAR(Data) =2014 AND CONT = ‘USA’ AND ROWNUM = 1 ; Something like this, but anyway I don’t think this is the … Read more
The ORDER BY clause should be the last, but you have to specify fields to be aggregated. Such as: SELECT surname, count(*) FROM people WHERE user_token=’$user_token’ GROUP BY surname ORDER BY surname 1 solved SELECT * FROM people WHERE user_id=’$user_id’ ORDER BY time GROUP BY surname [closed]