HomeFlySpeed SQL Queryhi

hi


I want to add two count results in a single query.

e.g I get two count results as below ..

select count(*) as count1 from Books where condition1

select count(*) as count2 from Books where condition2

Now I want add these two counts and get the total count.

Can I all these stuff in a single query ?

How do I do this in FlySpeed SQL ? I need help at this part...

pagoda | email
August 17 2012, 02:45 AM
Dear Pagoda,

select
(select count(*) as count1 from Books where condition1) +
(select count(*) as count2 from Books where condition2) as total

You may learn more about working with SQL queries in the SQL reference for your database server.
Sergey Smagin | email
2 hours, 2 mins since original post
I'm using flyspeed GUI ...Is it possible build this query using gui ?

or have to do it manually ?
pagoda | email
2 hours, 56 mins since original post
Yes, it is possible. Go to an empty Expression cell of the Query Columns grid below the Design area. Right click on it and select the "Insert sub-query" menu item; type "+", right click again and select the "Insert sub-query" menu item one more time. After that go to the Alias cell and type "total". You will see two sub-query tabs above the Design area. Go to each sub-query tab, add the Books table, click the asterisk item in the Field list, go to the Aggregate column of the Query Columns list and select "Count", add the necessary conditions.

You may find the Visual Query Builder user's guide at http://www.activequerybuilder.com/hs15.html
Sergey Smagin | email
5 hours, 10 mins since original post
yup that works...thanks
pagoda | email
8 hours, 4 mins since original post
This topic is closed