Hi,
I'm constructing a query that will performs a lot o datetime
calculumns to generate columns.
All that operations are dependent of a base calculum that is performed
on the query and its result is stored in a columna returned.
I wanna find a way of reusing this generated column, to avoid
reprocessing that calculumn to perform the other operations, cause
that query will be used in a critical application, and all saving is
few.
Thanks a lot. 2 2104
One approach is to use a view. Another is to use a derived table. For
SQL Server 2005 there is a third alternative, a Common Table
Expression (CTE).
All three alternatives require writing the query that returns the
computed column and then using that query in any of the three ways. So
we could have something like:
WITH Example AS
(SELECT A, B, C, <complex expressionas Complex
FROM X)
SELECT *
FROM Example
WHERE Complex = '20071225'
Roy Harvey
Beacon Falls, CT
On Mon, 22 Oct 2007 06:06:17 -0700, "brazil.mg.marc us.vinicius.lim a"
<ma*******@gmai l.comwrote:
>Hi,
I'm constructing a query that will performs a lot o datetime calculumns to generate columns. All that operations are dependent of a base calculum that is performed on the query and its result is stored in a columna returned.
I wanna find a way of reusing this generated column, to avoid reprocessing that calculumn to perform the other operations, cause that query will be used in a critical application, and all saving is few.
Thanks a lot.
>
>One approach is to use a view. Another is to use a derived table. For SQL Server 2005 there is a third alternative, a Common Table Expression (CTE).
All three alternatives require writing the query that returns the computed column and then using that query in any of the three ways. So we could have something like:
WITH Example AS (SELECT A, B, C, <complex expressionas Complex FROM X) SELECT * FROM Example WHERE Complex = '20071225'
>I thought to divide in steps the performation of the calculumns. In the first step create a view that execute the basic calculation, and create another views that reuse the alread done work.
But its seems to be very strange, cause its not a elegant solution.
Using views on views is one way to do it, but with the new feature of
Common Table Expression (CTE) in SQL Server 2005 we can avoid that.
You can have more than one CTE prefixing a command, and the succeeding
ones can reference the preceding ones. That means the nesting can all
be in the one command, much cleaner than views on views.
Roy Harvey
Beacon Falls, CT This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Rigs |
last post by:
Hi,
I'm a SQL Server newbie, so I'd appreciate if someone would tell me if
this is possible. I'm running SQL Server 2000 on Win2k Server
I have one table with a large number of columns. I have two pieces of
logic that I'd like to execute depending upon whether an insert or an
update statement was executed on that table. I'd prefer this
execution to occur from within a single trigger. If a row is
inserted, then I would like to...
|
by: Oleg Paraschenko |
last post by:
Hello,
I'd like to introduce an article which might be of some interest:
Reusing XML Processing Code in non-XML Applications
HTML: http://uucode.com/texts/genxml/genxml.html
PDF: http://uucode.com/texts/genxml/genxml.pdf
<abstract>
|
by: db2group88 |
last post by:
i would like to know when i create a table with identity column,
should i used generated by default or generated as always. since when
i create this table, i might copy some data from another table with
identity column also, (so if i use generated as always, i can't do
insert into new_tables select * from old_table), then i might also
insert new data into this new table (if i do generated by default,
then the new table could have the same...
|
by: Robert Stearns |
last post by:
I have two related questions. Why did I have to:
SET INTEGRITY FOR is3.animals OFF;
before doing:
alter table is3.animals
add column pseudo_id
generated always as
(coalesce(regnum, cast(bhid as char(10))));
|
by: valerio |
last post by:
Hi all,
I've some problem to import data to DB2 using the db2move and db2look
tools.
Follow the problem :
I have exported data from db2 v. 7 database on windows server, using
the db2look and db2move tools.
Then I moved the *.SQL and *.IXF files to the linux server, where is
installed DB2 v.8 fp 6.
| |
by: Mariano Drago |
last post by:
Hi there.
It will sound like a stupid question, but i cant figure out how to resolve
this...
Doing a little profiler job on the app im writing, i found a bottleneck in
some parts that involve DB access to retrieve User information.
Basically, i have an "User" class. The ctor of this class uses a method in
the data access layer. As you may figure it out, the method execs a SP and
pass the info back to the class, who load the data into...
|
by: Darek |
last post by:
Hi,
I have a table, something similar to:
create table my_table (
id char(32) not null primary key,
num integer not null,
code varchar(2) not null,
name varchar(60) not null,
|
by: Veeru71 |
last post by:
Given a table with an identity column (GENERATED BY DEFAULT AS
IDENTITY),
is there any way to get the last generated value by DB2 for the
identity column?
I can't use identity_val_local() as the INSERTS are happening in a
different session.
Eg, We have the following table....
|
by: Enrique Cruiz |
last post by:
Hello all,
I am currently implementing a fairly simple algorithm. It scans a
grayscale image, and computes a pixel's new value as a function of its
original value. Two passes are made, first horizontally and second
vertically. The problem I have is that the vertical pass is 3 to 4
times slower than the horizontal, although the code is _exactly_ the
same in both cases?!
The code itself is very simple. There are 2 loops to scan through...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |