Query output

  • can someone assist me in joining the two queries together into 1

    so that I can get one result set

    ---------------------------------------------------------

    SELECT count(ee_occup_levels) AS OcpLvl, ee_occup_levels AS [Occupation Levels], headcount

    FROM headcountdec

    WHERE period = 'March 2008' AND headcount ='NewHires' AND staffno IS NOT NULL AND ee_occup_levels is not null

    GROUP BY ee_occup_levels, race, gender, headcount

    ORDER BY gender, Race, ee_occup_levels, headcount

    select count(headcount + headcount) AS Transfares

    from headcountdec

    where Period = 'March 2008' AND headcount IN ('TransferOut', 'TransferIn')

    Thanx

    Thato

  • Hi

    canu give the table structure and some data to make thing clear. I think a derived table can be used for this.

    "Keep Trying"

  • How do the two queries relate? There doesn't appear to be a common column between them.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • The two statements are run on the same table. the problem is:

    The column headcount does not have a field called transfares, It only has two fields called 'transfarein' and 'transfareout'.

    I need to write a report in which I have to use both fields a one called 'transfares'. my second query gives me the results I want but I cant use it with the first query as I end up with wrong results.

  • The problem is the two statements have different where conditions and second has no group by clause, so you can't combine them.

  • thatok (5/14/2008)


    The two statements are run on the same table. the problem is:

    The column headcount does not have a field called transfares, It only has two fields called 'transfarein' and 'transfareout'.

    I need to write a report in which I have to use both fields a one called 'transfares'. my second query gives me the results I want but I cant use it with the first query as I end up with wrong results.

    Can you post what you want your final result set to look like?

    Also, what is the problem with having two separate result sets?

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply