Forum Replies Created

Viewing 12 posts - 46 through 58 (of 58 total)

  • Reply To: How show only first friday of every month

    I am always scared when I see code I don't understand. I will offer a solution that requires very little coding, once preparations are done. Later, date based calculations are...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: ADD Values from a table to an another table

    If you provide DDL (CREATE TABle) for at least Table_1 and some test data, perhaps somebody can help you write a trigger.

    Zidar's Theorem: The best code is no code at all...

  • Reply To: how to get quantity from yesterday 6pm till today 6pm

    Zidar's solution will always be in data modeling and table design 🙂

    The first thing to do is to add two calculated fields to the table design - that does not...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: how to get quantity from yesterday 6pm till today 6pm

    There are other methods, with less use of date functions. If uahmed90 provides CREATE TABLE statement and some reasonable test records, we could try another approach.

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Dictionary Lookup

    Good idea would be to leave "the lookup" to the SQL server, then pass the results to C# code. Something like:

    SELECT ID, NAme FROM DirectoryTable 
    WHERE ID...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: How to Create ER Diagrams for tables in a Non-relational Database

    Ravi77, you may bi in bigger trouble than it seems.

    In any case, you need to figure out what makes each table unique, does not have to be just one column....

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Need help sorting based on 2 different column DateTime

    Function coalesce() should also do the job. In this example, I assumed that order of using dates for sorting is LastReplied, IncidentDate, CreatedDate. I also reordered columns to my liking...

    • This reply was modified 4 years, 9 months ago by Zidar.

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Using Coalesce to Clean Up Reports

    Not directly about coalesce, but since we are also talking about ways to concatenate rows, worth checking is a relatively recent addition to T-SQL functions is string_agg (expression, separator) . ...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Seeking input on Best Method to Join on First or Last Row in a 1:M Join

    ROW_NUMBER in DESCending order, cool trick. Thank you SoCal_DBD. In spite being a newbie, I knew about this one, but hesitated to apply it  due to possible slow execution. Live...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Data type convert help

    Be careful with dates. Expression

     >= @StartDate AND < @EndDate  --- this will miss all rows within @end date

    >= @StartDate AND <= @EndDate --- this...

    Zidar's Theorem: The best code is no code at all...

  • Reply To: Storing the datediff between a row and the previous row

    I haven't been on SQL.Central for a long time, so i just noticed the post.

    Not sure if this is the simplest solution, but for sure is the shortest for typing:

    Zidar's Theorem: The best code is no code at all...

  • Reply To: what type of join is this?

    This is  INNER JOIN. In distant past, SQL did not have JOIN keword, so people used WHERE block to specify both JOIN condition and filters. Your statement would look like...

    Zidar's Theorem: The best code is no code at all...

Viewing 12 posts - 46 through 58 (of 58 total)