Forum Replies Created

Viewing 15 posts - 1 through 15 (of 36 total)

  • RE: Query for Running Totals with respect to dept's

    Can you just add this...

    ,(select sum(b.sal) from cte b where b.seq_no <= a.seq_no and b.deptno = a.deptno) as "RunningTotalWRTDept"

  • RE: A count of distinct rows from 2 tables

    I think you need:

    - left join

    - change the <> to not in

    - add or classnumber is null (because there will be no records for non TAs in the ta table)

    Select...

  • RE: Quarterly Breakdown

    Thanks for the info Jeff. Do you have a better way to do it?

  • RE: Quarterly Breakdown

    create table #temp (ID int, monthTotal int, EndPeriodDate datetime)

    insert into #temp

    select 1,200, '1/30/08'

    union all

    select 1, 500, '2/28/08'

    union all

    select 1, 300, '3/31/08'

    union all

    select 1, 600, '4/30/08'

    union all

    select 1, 300, '5/31/08'

    union all

    select...

  • RE: How can I find out which one of the variables is the greatest

    I know too many lines

    I did not account for a tie

    declare @a int

    declare @b-2 int

    declare @C int

    declare @d int

    set @a =...

  • RE: time

    Did you try my sample code? Does it work for you? What does your query look like?

  • RE: time

    Is this what you are looking for?

    declare @temp as table (t int)

    insert into @temp

    select 234000 --.65

    union all

    select 2052000 -- 5.7

    union all

    select 1638000 -- 4.55

    union all

    select 1620000 -- 4.5

    select...

  • RE: time

    Sorry, will this work? (note the one less zero on the 360000)

    select seconds = cast((2287045 / 36000) as float) / 10

  • RE: time

    Just use the round function:

    select seconds = round(2100045 / cast(360000 as float),1)

  • RE: time

    You can cast either number as a float like:

    select seconds = cast(2052000 as float) / 360000

    or

    select seconds = 2052000 / cast(360000 as float)

  • RE: DateTime Problem

    I don't know if you want to use a temp table but this should work

    select *

    into #temp

    from emp

    where isDate(fromdate) = 1

    select fromdate

    from #temp

    where cast(fromdate as datetime)>'2/16/2007'

  • RE: DateTime Problem

    Just cast fromdate (in the table) as a datetime like:

    select fromdate from emp where cast(fromdate as datetime)>'2/16/2007'

    as long as you are sure they are all valid datetimes otherwise the...

  • RE: sql query with count

    select state + '(' + cast(count(state) as varchar(2)) + ')'

    from theTable

    group by state

    order by count(state) desc, state

  • RE: Selecting range based on criteria

    How about...

    select *

    from @temp

    where v between 'joe' and 'ti'

    or v like 'joe%'

    or v like 'ti%'

     

Viewing 15 posts - 1 through 15 (of 36 total)