SQL query

Giganews Newsgroups
Subject: SQL query
Posted by:  Radu (cuca_macaii20…@yahoo.com)
Date: 2 Aug 2006

Hi. I have a table with the following *COLUMNS*:

PIN#
# of weeks when Overtime > 8
Overtime Week 1
Overtime Week 2
Overtime Week 3
..
..
..
Overtime Week 52

I need to calculate the # of times when in column "Overtime Week X" for
the current PIN# appears a number >=8, and write in column [# of weeks
when Overtime > 8] the number of times when this happens for the
current PIN.

Assume that for PIN 376 I have the following row:

PIN      Wk1    Wk2    Wk3    Wk4........
376    7        9        5        9

I have to write in column [# of weeks when Overtime > 8] the value 2
(the overtime for this guy is only twice greater than 8, as you can see
above).

How could I accomplish this, please ? I don't know how to attack this
problem.

Note - I think that if I had a transposed table (weekN being rows, not
cols), my problem would be easy. But how do I transpose my table
(actually, I am using Access, not SQL) ? I have 52 cols which should
become rows.....

Thank you very much.
Alex

Replies