Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 3 of 3 total |
Can this be done with single query? |
Wed, Dec 5 2007 2:23 PM | Permanent Link |
Kai | Hi ~
Given a table like this StaffID ClientID Date WorkType MinutesSpent --------------------------------------------------------------------- 10 22 2007-10-01 DC 90 10 44 2007-10-01 IC 270 10 33 2007-10-02 DC 120 10 22 2007-10-22 IC 105 10 22 2007-10-23 DC 30 Is is possible to obtain the following results with a *single* SQL query? ClientID DC Minutes IC Minutes -------------------------------------------------- 22 120 105 33 120 0 44 0 270 Thanks for all help, Kai |
Wed, Dec 5 2007 2:28 PM | Permanent Link |
"Robert" | Are the work types limited to DC and IC, or can you have any number?
If it is limited to those two, then it's simple SELECT CLIENTID, SUM (IF (WORKTYPE = DC THEN MINUTESSPENT ELSE 0)) DCMINUTES, SUM (IF (WORKTYPE = IC THEN MINUTESSPENT ELSE 0)) ICMINUTES, GROUP BY CLIENTID; Robert "Kai" <platysternon@hotmail.com> wrote in message news:A2A453FA-36A9-4D6C-923E-F494D6F193EB@news.elevatesoft.com... > Hi ~ > > Given a table like this > > StaffID ClientID Date WorkType MinutesSpent > --------------------------------------------------------------------- > 10 22 2007-10-01 DC 90 > 10 44 2007-10-01 IC 270 > 10 33 2007-10-02 DC 120 > 10 22 2007-10-22 IC 105 > 10 22 2007-10-23 DC 30 > > Is is possible to obtain the following results with a *single* SQL query? > > ClientID DC Minutes IC Minutes > -------------------------------------------------- > 22 120 105 > 33 120 0 > 44 0 270 > > Thanks for all help, > Kai > |
Wed, Dec 5 2007 2:33 PM | Permanent Link |
Kai | "Robert" <ngsemail2005withoutthis@yahoo.com.ar> wrote:
Are the work types limited to DC and IC, or can you have any number? Yes, work types is limited to a handful of values - so your solution works great! Thanks, Kai |
This web page was last updated on Saturday, May 4, 2024 at 09:18 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |