Skip to main content

F M's Library tagged SQL   View Popular

04 May 08

SQL Server programming Select DISTINCT columns along with a NON-DISTINCT column

  • I tried to do the same thing myself and finally this is how I worked it out :



    SELECT

    rowCode <---- (Some unique numeral key)

    firstname,lastname,address1 <---- distinct columns

    plandate,plandate2 <---- non distinct columns



    FROM table



    WHERE rowCode IN (SELECT Min(rowCode) FROM table GROUP BY firstname,lastname,address1)



    ORDER by firstname



    This will return unique values for your distinct columns and will the first (min) value of your non distinct columns .

    ---------------------------------------------------



    Actually in your case, because your 'non distinct' column has a 'date' type, you can solve it more easily by using the following code :



    SELECT Bank, Account, Note, MAX(PlanDate)

    FROM table

    GROUP BY Bank, Account, Note
02 May 08

SQLNINJA

New version of SQLNinja, Well done icesurfer

sqlninja.sourceforge.net - Preview

SQL Injection Shared Furl Imports

SQL UNION and UNION ALL

\n <clipping>The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.</clipping>\n

www.w3schools.com/...sql_union.asp - Preview

SQL Injection SQL

Time-Based Blind SQL Injection with Heavy Queries: MVP Article of the Month - September 2007

Clever Blind SQL Injection trick when you can&apos;t use BENCHMARK, WAITFOR DELAY, sleep etc.

Should be used as a last resort.

www.microsoft.com/...sv0907.mspx - Preview

SQL Injection Shared Furl Imports

1 - 13 of 13
Showing 20 items per page

Highlighter, Sticky notes, Tagging, Groups and Network: integrated suite dramatically boosting research productivity. Learn more »

Join Diigo