Help Newbie here, new to sql

  • Thanks guys resolved.

  • How did you fix it in the end?


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • It hasn't actually resolved because now anything in base is showing as a base currency.

    I put the G/L as a left join and anything I had in the where clause related to the G/L table was included in the joining clause rather than where but now it seems to give anything in base currency a null value.

    Any suggestions?

  • imran.shah (10/14/2014)


    It hasn't actually resolved because now anything in base is showing as a base currency.

    I put the G/L as a left join and anything I had in the where clause related to the G/L table was included in the joining clause rather than where but now it seems to give anything in base currency a null value.

    Any suggestions?

    Yes. Post some sample data that exhibits the problem as previously suggested. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi Jeff,

    Should I re-format my code with comments and upload? or upload how the sample report now appears?

    Thanks

  • Have a look the example below.

    create table #EventHeader(

    HistoryIDint primary keynot null

    ,DateTimeHappened datetimenot null

    )

    create table #EventDetail

    (

    HistoryIDint

    ,DetailIDint primary key not null

    ,DateTimeProcessed datetimenot null

    ,ProcessedBy varchar(20)not null

    )

    insert into #EventHeader

    select 100001, '2014-07-23 08:50:00.123' union all

    select 100002, '2014-07-23 08:51:00.123' union all

    select 100003, '2014-07-23 08:52:00.123' union all

    select 100004, '2014-07-23 08:53:00.123' union all

    select 100005, '2014-07-23 08:54:00.123' union all

    select 100006, '2014-07-23 08:55:00.123' union all

    select 100007, '2014-07-23 08:56:00.123' union all

    select 100008, '2014-07-23 08:57:00.123' union all

    select 100009, '2014-07-23 08:58:00.123' union all

    select 100010, '2014-07-23 08:59:00.123'

    insert into #EventDetail

    select 100001,200001, '2014-07-23 08:50:07.123','System1' union all

    select 100001,200002, '2014-07-23 08:50:08.123','System2' union all

    select 100001,200003, '2014-07-23 08:54:09.123','APerson' union all

    select 100002,200004, '2014-07-23 08:51:07.123','System1' union all

    select 100002,200005, '2014-07-23 08:51:08.123','System2' union all

    select 100002,200006, '2014-07-23 08:57:09.123','APerson' union all

    select 100003,200007, '2014-07-23 08:52:08.123','System1' union all

    select 100003,200008, '2014-07-23 08:52:07.123','System2' union all

    select 100003,200009, '2014-07-23 08:59:09.123','APerson' union all

    select 100004,200010, '2014-07-23 08:53:07.123','System1' union all

    select 100004,200011, '2014-07-23 09:00:09.123','APerson' union all

    select 100005,200012, '2014-07-23 08:54:07.123','System1' union all

    select 100006,200013, '2014-07-23 08:55:08.123','System1' union all

    select 100007,200014, '2014-07-23 08:56:09.123','System1' union all

    select 100008,200015, '2014-07-23 08:57:07.123','System1' union all

    select 100009,200016, '2014-07-23 08:58:08.123','System1' union all

    select 100010,200017, '2014-07-23 08:59:09.123','System1'

    select distinct

    eh.HistoryID

    ,min(ed.DateTimeProcessed) over (partition by eh.HistoryId)

    from

    #EventHeader eh

    join #EventDetail ed on ed.HistoryID = eh.HistoryID

    drop table #EventHeader, #EventDetail

    What we'd like you to do is post some data in that kind of format so we can more easily see what is wrong. You don't need to include your actual data just something that looks like it. It will make it much easier to see the problem. Please read the article I posted earlier too.


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • Hi Guys,

    Cracked it, report is working fine.

    Thanks

  • What was the fix?

    Chris Powell

    George: You're kidding.
    Elroy: Nope.
    George: Then lie to me and say you're kidding.

Viewing 8 posts - 16 through 22 (of 22 total)

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