Forum Replies Created

Viewing 15 posts - 1,111 through 1,125 (of 1,496 total)

  • RE: Help with a troublesome query.

    I started the query with the PO_MX table as you were looking for PONumbers - I find this easier but you can start with any table you like.

    You should also...

  • RE: Help with a troublesome query.

    In addition, derived tables, also known as inline views, could be used instead of HAVING:

    SELECT PO_MX.PONumber

    FROM PO_MX

    &nbsp&nbsp&nbsp&nbspJOIN

    &nbsp&nbsp&nbsp&nbsp(

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSELECT EJ.PONumber, SUM(EJ.Amount) AS Amount

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspFROM EJ

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspGROUP BY EJ.PONumber

    &nbsp&nbsp&nbsp&nbsp) D1

    &nbsp&nbsp&nbsp&nbspON PO_MX.PONumber = D1.PONumber

    &nbsp&nbsp&nbsp&nbspJOIN

    &nbsp&nbsp&nbsp&nbsp(

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspSELECT PO_DX.PONumber, SUM(PO_DX.QuantityOrdered...

  • RE: rownumber

    Without DDL and test data it is difficult to know what you want.

    Maybe you need to use the ROW_NUMBER() function like:

    SELECT *

    FROM

    (

    &nbsp&nbsp&nbsp&nbspSELECT ROW_NUMBER() OVER (PARTITION BY S.sessie_id ORDER BY S.created_date)...

  • RE: Add incremental count to group of rows

    1. Create a #temp table with an IDENTITY column

    2. Insert your data into the #temp table

    3. Join the #temp table to a derived table containing the MINIMUM(ID) for each tans_code...

  • RE: Add incremental count to group of rows

    In SQL2000 you will need to use a #temp table:

    http://www.sqlservercentral.com/Forums/Topic397675-8-1.aspx

  • RE: Date range issues

    The UNIONS are test data! (Read the comments.)

    Just use the query and replace the test tables with your tables.

  • RE: Date range issues

    -- *** Test Data ***

    DECLARE @t1 TABLE

    (

    &nbsp&nbsp&nbsp&nbspInitials varchar(10) NOT NULL

    &nbsp&nbsp&nbsp&nbsp,EffectiveDate datetime NOT NULL

    &nbsp&nbsp&nbsp&nbsp,RatePerHour money NOT NULL

    )

    INSERT INTO @t1

    SELECT 'aaaa', '20050101', 150 UNION ALL

    SELECT 'aaaa', '20050705', 200 UNION ALL

    SELECT 'aaaa', '20050901',...

  • RE: Left outer join in where clause

    Without the rest of your tables (P as in P.Tran_ID?) and the rest of the WHERE clause, your post does not make sense.

  • RE: Dead lock issue

    Try:

    INSERT INTO table_geography

    SELECT @geolevel

    WHERE NOT EXISTS

    (

    &nbsp&nbsp&nbsp&nbspSELECT *

    &nbsp&nbsp&nbsp&nbspFROM table_geography G WITH (UPDLOCK )

    &nbsp&nbsp&nbsp&nbspWHERE G.geolevel = @geolevel

    )

  • RE: Uploading Tiff files using SQL 2005 and not using any application

    I have a note that the following should work in 2005. (I must have seen it on a forum somewhere.) I have never tried it as ADO/ADO.Net seems less hassle.

    CREATE...

  • RE: I don't want SQL Server to order the data

    Gail is right to say that order is meaningless in a SQL table, however order does have meaning in your Excel worksheet. In order to retain this order in SQL...

  • RE: multiple nested select statments in 1 query

    JReed,

    I find all the unneeded brackets in code makes it difficult to read. I have reformatted it as follows:

    SELECT DISTINCT

    &nbsp&nbsp&nbsp&nbspAccounts.UID

    &nbsp&nbsp&nbsp&nbsp,Accounts.Fname + ' ' + Accounts.MI AS Fname

    &nbsp&nbsp&nbsp&nbsp,Accounts.Lname...

  • RE: NOT IN condition

    Your queries are running correctly, NOT IN and NOT EXISTS are not the same when there are NULLs involved and ANSI_NULLs are on. (Your data must have NULLs in the...

  • RE: HashBytes Function - Change varbinary output

    Try casting to bigint and using the fnNumber2AnyBase function at the following link.

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=87871

  • RE: need help in query

    Conceptually in SQL the FROM clause is evaluated first and then the results are filtered by the WHERE clause.

    Think about what you are doing! Will NULL = 46 ever be...

Viewing 15 posts - 1,111 through 1,125 (of 1,496 total)