0

I've found a few things about hiding columns in queries, but none of them have worked.

In my query below, I don't want the "NextRow" to display in the output.

SELECT * 
    FROM (SELECT *, LAG([Cupola_Charge_Counter]) OVER (ORDER BY DateTime) NextRow
    FROM OPENQUERY(INSQL, 
        'SELECT DateTime, [Cupola_Charge_Counter], [Cupola_Charge_Steel], [Cupola_Charge_Cast], [Cupola_Charge_Remelt],  [Cupola_Charge_Pig], [Cupola_Charge_Borings]
            FROM WideHistory
            WHERE wwRetrievalMode = ''Full''
            AND wwVersion = ''Latest''
            AND DateTime >= DateAdd(hh,-24,GetDate())
            AND DateTime <= GetDate()')
    ) X 
    WHERE NextRow <> [Cupola_Charge_Counter]
    ORDER BY DateTime DESC
Degan
  • 989
  • 2
  • 16
  • 30
idnarbjm
  • 13
  • 4

2 Answers2

1

You are using *. That is shorthand for all rows. If you only want certain rows, then instead of using *, specify which rows you want. Example:

SELECT id, name, phone FROM...
Goose
  • 4,764
  • 5
  • 45
  • 84
  • Can't believe I looked right past that. Thank you for pointing it out. That worked perfectly. – idnarbjm Jul 11 '18 at 12:07
  • @idnarbjm Glad to hear it. Please click the checkmark next to my answer accept it if you found it helpful. – Goose Jul 11 '18 at 13:20
0

You can't use the asterisk and do this. It's going to take more time, but you're going to having to type every attribute that you want, but you'll still be able to reference NextRow in your query.

DarthTommy
  • 419
  • 2
  • 10