-1
I’m willing to put a condition for each column in my SELECT, this is possible?
SELECT count(id_casa) as casaAzul, count(id_casa) as casaAmarela FROM tb_casa
Where: Where column 1: Where cor_casa = 'blue' Where column 2: Where cor_casa = 'yellow'
So, what if I want to count the houses that have the number greater than 500 and less than 500 ? I use the in(n_casa > 500, n_casa < 500) ?
– Leandro Kojima
Yes, you can. But do you want to put the two clauses in the same select? I ask because if you put < 500 and > 500, all the numbers will come except the 500. Then it would be simpler if you put a clause just saying n_casa other than 500 (in Oracle is the symbol different is <>, in Mysql should be this or !=). Now, if you want to do it separately, just include a clause AND N_CASA > 500 , and then make another select with AND N_CASA < 500
– MarceloBambino
In fact, this was just one example, the real problem is that: I have a list of trucks, where I sort whether they are light or heavy from a calculation. I want to separate the quantity of the weighed and the quantity of the other grouped by date. RESULT: | Date | Heavy | Other | | 10/04/2014 | 121 | 45 | | 11/04/2014 | 355 | 121 | . . .
– Leandro Kojima
Only one addendum: The "in" command functions as an OR. In this example you could put: Where COR_CASA in ('blue', 'yellow') or Where COR_CASA = 'blue' OR COR_CASA = 'yellow'. They are both equivalent. That your filter n_casa > 500 goes with an AND clause because you want the houses to be blue/yellow And the number to be more than 500.
– MarceloBambino
I understand your doubt.. in this case you will have to group by date and by truck type. Is this truck date and type information in a single table? What is the table name and the name of these columns?
– MarceloBambino
They are in a table, the table is called tb_vbv, I define whether they are weighed or not by a column called Gross, where they are weighed if Gross > 12600 and others if Gross < 12600
– Leandro Kojima
I get it.. what’s the name of the date column you need to show ?
– MarceloBambino
The column name is date
– Leandro Kojima
Let’s go continue this discussion in chat.
– MarceloBambino