Forum Replies Created

Viewing 15 posts - 16 through 30 (of 33 total)

  • RE: Re Pivoting a table

    What you posted makes sense. I tried it out for those two entry codes WFC & DCM and it seems to work fine, with the exception that I had to...

  • RE: Percentage Calculation

    Good point, I would create a view, however w/ the amount of data that will be contained in the table (millions of rows) the requirement is aggregate all data first,...

  • RE: Percentage Calculation

    Thanks for pointing me in the right direction. Utilizing your logic, I modified my query as shown below:

    SELECT

    cast(C.LABORLEV3DSC + '(' + C.LABORLEV3NM + ')' as varchar(255))AS Facility,

    cast(C.LABORLEV2DSC + '('...

  • RE: Percentage Calculation

    Here's the table design

    CREATE TABLE [dbo].[PunchTrend] (

     [Facility] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [District] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [Division] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,

     [EntryType] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL...

  • RE: Output Individual Months w/ Total for Date Range

    The requirements have changed a bit so I removed the date range clause and inserted the data into a flat table that looks like this:

  • RE: Output Individual Months w/ Total for Date Range

    Wow, maybe someday I'll be as good @ sql as I am at Flash programming...Im impressed...

    Thanks again, I assume you're a dba? TSQL is fairly new to me, in my...

  • RE: Output Individual Months w/ Total for Date Range

    Unfortunately, I can't change the layout. However, the project requirements have changed and now I will be able to use a stored proc. So I'll take your original query and...

  • RE: Output Individual Months w/ Total for Date Range

    That worked really well. What do the think would be the best way to limit the month output to the current month -  1? I need to show a range...

  • RE: Problem w/ Grouping & Count

    I see...i had the not null in the wrong place...

    It works great now...thanks for your quick and meaningfull replies...

    I'm heading home for the day...

  • RE: Problem w/ Grouping & Count

    Ok, that makes sense...so here's the final joining to the additional tables that i needed...

    Thanks again...

    SELECT

     A.FacilityID,

     SUM( CASE WHEN DateHired is not null THEN 1 ELSE 0 END) AS '#...

  • RE: Problem w/ Grouping & Count

    Ok, I think this is the final...thanks for your advice...

     

    SELECT

     A.FacilityID,

     SUM( CASE WHEN DateHired is not null THEN 1 ELSE 0 END) AS 'HireCnt',

     SUM( CASE WHEN DateHired is null...

  • RE: Problem w/ Grouping & Count

    Yep that works great. It return null for the TermsCnt column if there is no data...

    How can I display 0 instead of null in that column?

  • RE: Problem w/ Grouping & Count

    I had tried right join as well and it returns the same set of data.

    Do i have specify the plan year in the sub query? As i mentioned in my...

  • RE: Problem w/ Grouping & Count

    Well, this is what i have so far. It seems to work fine as long as I specify the Plan Year in the derived table. Also if there are no...

  • RE: Problem w/ Grouping & Count

    One more quick question regarding my original post.

    How should I restructure my query to accommodate more tables?

    Should I have separate queries that hit each table from which i needed counts...

  • Viewing 15 posts - 16 through 30 (of 33 total)