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.

It is unclear what you exactly want to achieve. Bot hof your queries are identical.

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.