0

Hi all,

I am fairly new when it comes to SQL... and i would like some help

I would like to run 2 select statements in the same time...in order to get my results in a table with 2 columns and 2 rows that shows me the result of my queries

1st query:

select  count(serviceid)
from serviceslog
where serviceid='3'
and partition not like '%test%'
and component not like '%test%'
and component not like '%do not bill%'
and occurence between '2009-05-01 05:00:00' and '2009-06-01 04:59:59'
group by serviceid;

2nd query:

select  count(serviceid)
from serviceslog
where serviceid='3'
and partition not like '%test%'
and component not like '%test%'
and component not like '%do not bill%'
and occurence between '2009-05-01 05:00:00' and '2009-06-01 04:59:59'
group by serviceid;

Any help would be appreciated.

4
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by Tulsa
0

Mean something like this?

select  '1' as rownum, count(serviceid) as id
from serviceslog
where serviceid='1'
and partition not like '%test%'
and component not like '%test%'
and component not like '%do not bill%'
and occurence between '2009-05-01 05:00:00' and '2009-06-01 04:59:59'
group by serviceid

union
 
select '2' as rownum, count(serviceid) as id
from serviceslog
where serviceid='3'
and partition not like '%test%'
and component not like '%test%'
and component not like '%do not bill%'
and occurence between '2009-05-01 05:00:00' and '2009-06-01 04:59:59'
group by serviceid
0

hi
If you want all same fields for different id than you can use 'in ' with where clause.

select  count(serviceid) as id
from serviceslog
where serviceid in ('1','2')
and partition not like '%test%'
and component not like '%test%'
and component not like '%do not bill%'
and occurence between '2009-05-01 05:00:00' and '2009-06-01 04:59:59'
group by serviceid

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.