home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / database / sybase / 636 < prev    next >
Encoding:
Text File  |  1993-01-08  |  1.3 KB  |  48 lines

  1. Newsgroups: comp.databases.sybase
  2. Path: sparky!uunet!mnemosyne.cs.du.edu!mercury.cair.du.edu!diana.cair.du.edu!elinden
  3. From: elinden@diana.cair.du.edu (Elwood Blues)
  4. Subject: Query Question 
  5. Message-ID: <1993Jan8.204249.6995@mercury.cair.du.edu>
  6. Sender: news@mercury.cair.du.edu (netnews)
  7. Organization: University of Denver, Denver, Colorado
  8.  
  9. Date: Fri, 8 Jan 93 20:42:49 GMT
  10. Lines: 36
  11.  
  12. I am querying a payroll table and want to list the year to date hours
  13. by store for four different pay code (reg, OT, sunday, sundayOT)
  14.  
  15. Basically the query is as follows:
  16.  
  17. select store, paycode, sum(hours)
  18. from payroll
  19. where paycode in ('reg','OT','sunday','sundayOT')
  20. group by store, ecode
  21. go
  22.  
  23. This gives me the correct results in the form 
  24. store  code    hours
  25. ---------------------
  26. store1 reg     800
  27. store1 OT      40
  28. store1 sunday  30
  29. store1 sundayOT 10
  30. etc.
  31.  
  32. What I want is for one record per store and 5 columns as follows
  33.  
  34. store   reg   OT      sunday     sundayOT 
  35. -------------------------------------------
  36. store1  800   40      30         10
  37. etc.
  38.  
  39. Any ideas would be greatly appreciated.  There are many circumstances in which
  40. I would like to have a single field (hours) displayed in multiple columns.
  41.  
  42. Thanks
  43.  
  44. Eric Linden
  45. elinden@diana.cair.du.edu
  46. DBA/Safeway Inc./Denver Division
  47.  
  48.