union all and ordering the data

  • Hi all,

    I have a table called booking with some data with e.. ID, Timstamp,period,weeknumber and some more.

    I need to show some dat aon a ASP.Net site and I'll use four seperate gridviews. But I want to reduce it to one.

    The purpose is to select all data within a period. Every period exists of four weeks. Period 9 is week 35,36,37 and 38. After every week I present a calculated value of a field, called daytotal, presented below the details of a week. I thought I could use the UNION ALL statement, but this will fail in the order section.

    How can I solve this problem ?

    Kind regards,

    Piet Kouwer

  • You can't use order by at the union all level, it must be after...

    SELECT * from master.sys.columns

    UNION ALL

    SELECT * FROM msdb.sys.columns

    --the union all is now formed into a single dataset

    ORDER BY Whatever.

    You might also want to consider GROUP BY WITH CUDE or also grouping sets.

  • How nice for you!

    O Yes it is nice !

    Gridview? Who cares? This is an SQL forum.

    ever heard of background information wich can be usefull to share ?

    It sounds like you are trying to do display formatting in SQL! NO!

    wrong point of view mister

  • piet.kouwer (9/6/2011)How can I solve this problem ?

    There are several ways of achieving this but we need more information

    DDL to create tables

    Sample data (INSERT statements)

    Expected results

    Far away is close at hand in the images of elsewhere.
    Anon.

  • David Burrows (9/7/2011)


    piet.kouwer (9/6/2011)


    How can I solve this problem ?

    There are several ways of achieving this but we need more information

    DDL to create tables

    Sample data (INSERT statements)

    Expected results

    Agreed. With a little more background info, many of us can provide better (more helpful) answers/solutions.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Piet,

    Maybe you haven't been in this game long enough to know who Joe Celko is. Not for nothing, but if he talks, you should listen.

  • notoriousdba (9/7/2011)


    Piet,

    Maybe you haven't been in this game long enough to know who Joe Celko is. Not for nothing, but if he talks, you should listen.

    For the 1% of usefull posts out there I wouldn't bother.

  • notoriousdba (9/7/2011)


    Piet,

    Maybe you haven't been in this game long enough to know who Joe Celko is. Not for nothing, but if he talks, you should listen.

    I will listen, but I don't care who someone is. Just respect everyone, even the beginners like me....

  • piet.kouwer (9/7/2011)


    notoriousdba (9/7/2011)


    Piet,

    Maybe you haven't been in this game long enough to know who Joe Celko is. Not for nothing, but if he talks, you should listen.

    I will listen, but I don't care who someone is. Just respect everyone, even the beginners like me....

    Maybe if more of you answered like that Joe would finally get it. Lost hope after all those years :-D.

  • piet.kouwer (9/7/2011)


    notoriousdba (9/7/2011)


    Piet,

    Maybe you haven't been in this game long enough to know who Joe Celko is. Not for nothing, but if he talks, you should listen.

    I will listen, but I don't care who someone is. Just respect everyone, even the beginners like me....

    Yes - agreed.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I will respect those who knows a lot of something, so I'll expect some respect too. He started SQL once and asked "stupid" of basic questions too.

    I hate replies like he did, even he is God or Bill Gates himself.....

  • piet.kouwer (9/7/2011)


    I will respect those who knows a lot of something, so I'll expect some respect too. He started SQL once and asked "stupid" of basic questions too.

    I hate replies like he did, even he is God or Bill Gates himself.....

    That's so polite of you. I think he thinks he's better than those as well :hehe:.

  • That's so polite of you. I think he thinks he's better than those as well :hehe:.

    Sound like a little sarcastic to me or am I wrong ?

    I hope he reads this topic and learn something about is....

  • piet.kouwer (9/7/2011)


    That's so polite of you. I think he thinks he's better than those as well :hehe:.

    Sound like a little sarcastic to me or am I wrong ?

    I hope he reads this topic and learn something about is....

    I'm not sure I was too sarcastic here. He's been around here at least since 2k5 IIRC. He never changed even if he got warning, told do, flammed at least 1000 times over the years (just here). Same case all over the net.

  • Ninja's_RGR'us (9/7/2011)


    piet.kouwer (9/7/2011)


    That's so polite of you. I think he thinks he's better than those as well :hehe:.

    Sound like a little sarcastic to me or am I wrong ?

    I hope he reads this topic and learn something about is....

    I'm not sure I was too sarcastic here. He's been around here at least since 2k5 IIRC. He never changed even if he got warning, told do, flammed at least 1000 times over the years (just here). Same case all over the net.

    I am told he behaves much differently in person. His forum persona comes off as abrasive though.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

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

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