jeudi 14 juillet 2016

SQL join 2 queries in one from same table

I have a table like that

IVA

id - taxa - name   - date
1  - 0.18 - normal - 1/1/2014
2  - 0    - none   - 1/1/2014 
3  - 0.23 - max    - 1/1/2013
4  - 0.16 - normal - 1/1/2015
...

I have an IVA.id from a product and I want to know in current date what is the taxa.

So I have to query this table twice:

Select name 
from IVA 
where id = 1; (return me normal)

Select taxa 
from IVA 
where name = 'normal' 
  and date <= '12/12/2015'; 

Can I join these two queries into only one?

Thanks

Aucun commentaire:

Enregistrer un commentaire