Skip to content

Tag: mysql

MySQL : calculate SUM of a Query

i have a mysql query that looks like this : The query returns a table b : I want to do the sum of those values By but it doesn’t work because of a syntax error. is it possible to sum a query like this ? Thanks. Answer Try this:

Why does my SQL Statement not SUM() up correctly?

I have the following statement: note that = (1 or 4) refers to two statements in the database where 1 is sold and 4 is a refund. With = (1)) I get the following results: Costs – Unitamounts 3.281,10 – 582 With = (4)) I get the following results: Costs – Unitamounts -115,2 – -32 With = …

WITH queries with INSERT in MySQL

I’m trying to do something that I’m almost positive works in Postgresql: In other words, I want to grab the “something” row to be used for a bunch of new rows in “somwhere”. Each new entry should have a reference (like foreign key value) back to the same “something&#8…

grouping equal values – aggregate function problem

I’ve created a table that lists venues in which several events take place. The same event in the same venue can have a different price. The last column calculates the total revenue for one venue. venue event totalprice sum Venue A Event A 5 30 Venue A Event A 10 30 Venue A Event B 5 30 Venue A Event

MySQL: LEFT JOIN TWO tables with preference for specific rows

Offshoot of this question: MySQL: LEFT JOIN table with preference for specific rows I have a Contacts table, a PhoneNumbers table, and a ContactPhoneNumber table. Additionally, I have a ContactAddress and Address tables. A Contact can haveMany PhoneNumbers via the ContactPhoneNumber pivot table and can also h…

How can I change the grammar in mysql?

in my query result However, if you search after changing the trdDtTm format, the results will not come out. How do I fix it? no items.. how to fix it? Answer trdDtTm is a datetime column. compares a datetime with a number hence. This makes hardly sense. Maybe you hope for the DBMS to magically match the two, …