September 18, 1998

using COUNT and GROUP BY with zero-values

Question: I’m trying to query our Human Resources database to find the number of temporary employees in each department. I’m using the following SQL statement: select count (*)from employeewhere status = ‘Temporary’group by departments; I expect the following results: 3004202 but am getting: 3422 That is, the zero-count departments are


Question: I have a table like this: name cat1 cat2—- —— —–A 1 orangeA 1 orangeB 1 appleB 1 appleB 1 appleC 2 bananaC 2 bananaC 2 bananaC 2 banana How can I form the query so that the result willbe: cat2 cat1 count(cat2)—- —- ———–orange 1 2apple 1 3banana

adding records but not using primary key

Question: Is there any other way apart from using the INSERT INTO command that allows you to append a line to a database? I have a primary key “ID,” but can I add a record without having to know what the next available unused ID is? Answer: For SQL Server

Can PB act as a COM Server

Question: I am working with a client that has a Powerbuilder application. We need to call that app through a variety of APIs. The client says that they cannot act as a COM server, but documentation I see on this site seems to contradict that. What is required for PB

Adding a userobject to a userobject at run-time?

Question: How can I dynamically add a visual userobject to a visual userobject? The PB documentation mentions how to add a userobject to a window at run-time, but not how to add one to a userobject. Answer: It’s the same principle as adding an object to the window. You can


Question: I have a select query “Select * from Table where ID in (8, 2,3,78,32,1,7)” that I want returned in the same order that the IDs are in in the IN statement. By default SQL will return them sorted by the primary key (which is the ID). How can I

SQL order by count

Question: I need to know how to order by the count of the selected field. For example: Select xxx count(xxx)from prod-tableorder by xxxI’d like to order/rank field xxx highest to lowest.Answer: You want to write:select xxx,count(*)from prod-tablegroup by xxxorder by count(*)

Connection Limits to SQL Server?

Question: Is there a limit to the number of connections to an SQL server? If so, how many connections are permitted at one time? Answer: The number of connections is a configuration option. You can see the current value by executing sp_configure and looking at the row that says “user

Titles of SQL reports

Question: Is there a way to title report outputs in SQL? Answer: If you are creating a quick and dirty report, you can always add a title simply by putting a “print” statement before your SQL statement. However, for almost any type of report, you are better off using a

No more posts to show