idnarbjm
idnarbjm

Reputation: 13

How can I hide columns that I need for the query

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

Upvotes: 0

Views: 522

Answers (2)

DarthTommy
DarthTommy

Reputation: 457

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.

Upvotes: 0

Goose
Goose

Reputation: 4821

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...

Upvotes: 1

Related Questions