Skip to content

MySQL get the SUM of different currencies

In a MySQL database To get the SUM of a column I just do: Is it possible in only one SQL request to get the SUM of orderamount_total of the different curriences defined in the column currency? Answer You just need a group by

Unable to replace the hour in datetime using SQL

Unable to replace the hour part in date-time. The change is reflecting in both hour & year. Please help in rectifying the code. Expected output = 2021-02-13 11:35:32.337 Actual output = 1121-02-13 11:39:11.347 Expected output = 2021-02-13 22:35:32.337 Actual output = 2221-02-13 22:38:13.223 Answer REPLACE…

how to fetch email address from oracle database

Hi All i am trying to fetch certain email patterns from oracle db 11g i have used the below queries Unfortunately i have to scan through the complete schemas in order to fetch the value (@pqr.de) where ever it exists in which ever column and table it is residing , ideally this activity is to list out inactive…

How can I find the right size box for each product?

I am sorry for re-uploading this quesiton, but I really want the answer. Kindly allow me to ask this question again and hope your kind support. The question is to find the right size box which allow the logistic business to save the money when shipping. We have 2 tables which are boxes and products. Boxes tab…

LEFT JOIN WHERE not returning results

There are two tables with columns and I’m doing a basic LEFT JOIN: Case 1 Result: All good! Case 2, applied on same records Result: I was expecting to return doe’s records but it returned nothing. What am I missing? Answer Ah, the wonderful world of NULL handling. The problem arises when doing a c…

SQL – Get multiple values when limit 1

If I have a table like this: And use this query: SELECT ident,COUNT(*) FROM sales WHERE status=? AND team=? AND DATE(date) = DATE(NOW() – INTERVAL 1 DAY) GROUP BY ident order by COUNT(*) DESC LIMIT 1 I get the value: cucu1, since that has the most rows. But if my table is like this: It should return bot…