home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.databases.sybase
- Path: sparky!uunet!mnemosyne.cs.du.edu!mercury.cair.du.edu!diana.cair.du.edu!elinden
- From: elinden@diana.cair.du.edu (Elwood Blues)
- Subject: Query Question
- Message-ID: <1993Jan8.204249.6995@mercury.cair.du.edu>
- Sender: news@mercury.cair.du.edu (netnews)
- Organization: University of Denver, Denver, Colorado
-
- Date: Fri, 8 Jan 93 20:42:49 GMT
- Lines: 36
-
- I am querying a payroll table and want to list the year to date hours
- by store for four different pay code (reg, OT, sunday, sundayOT)
-
- Basically the query is as follows:
-
- select store, paycode, sum(hours)
- from payroll
- where paycode in ('reg','OT','sunday','sundayOT')
- group by store, ecode
- go
-
- This gives me the correct results in the form
- store code hours
- ---------------------
- store1 reg 800
- store1 OT 40
- store1 sunday 30
- store1 sundayOT 10
- etc.
-
- What I want is for one record per store and 5 columns as follows
-
- store reg OT sunday sundayOT
- -------------------------------------------
- store1 800 40 30 10
- etc.
-
- Any ideas would be greatly appreciated. There are many circumstances in which
- I would like to have a single field (hours) displayed in multiple columns.
-
- Thanks
-
- Eric Linden
- elinden@diana.cair.du.edu
- DBA/Safeway Inc./Denver Division
-
-