Hello guys, I need help in something as I don't know if it is possible
what I want.
I have a select like this...
SELECT Cod1 as SQL, Cod2 as Oracle FROM table
and I need to sort by alias SQL or Oracle as the select is composed
dinamically so it could be either Cod1 as SQL or Cod2 as SQL and the
user needs to filter the data using SQL or ORACLE.
I need something like this:
SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE SQL = 'one' AND
Oracle = 'two'
Any ideas?
Thank you 4 1781
Hi
I don't understand what you mean. Is the column SQL, SQL Server Code and the
column Oracle, Oracle Code? If so why would the alias SQL be 'one' and the
alias Oracle be 'two' SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE SQL = 'one' AND Oracle = 'two'
As written I assume you mean something like
Select SQL, Oracle from
(SELECT Cod1 as SQL, Cod2 as Oracle FROM table) ss
WHERE SQL = 'one' AND Oracle = 'two'
Which is the same as
SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE Cod1 = 'one' AND Cod2 =
'two'
neither of which appear to be too useful.
Please post some DDL and expected output.
--
-Dick Christoph
"Pumkin" <Po********@gma il.com> wrote in message
news:11******** **************@ z34g2000cwc.goo glegroups.com.. . Hello guys, I need help in something as I don't know if it is possible what I want. I have a select like this...
SELECT Cod1 as SQL, Cod2 as Oracle FROM table
and I need to sort by alias SQL or Oracle as the select is composed dinamically so it could be either Cod1 as SQL or Cod2 as SQL and the user needs to filter the data using SQL or ORACLE.
I need something like this:
SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE SQL = 'one' AND Oracle = 'two'
Any ideas?
Thank you
On 24 Mar 2006 04:20:49 -0800, Pumkin wrote: Hello guys, I need help in something as I don't know if it is possible what I want. I have a select like this...
SELECT Cod1 as SQL, Cod2 as Oracle FROM table
and I need to sort by alias SQL or Oracle as the select is composed dinamically so it could be either Cod1 as SQL or Cod2 as SQL and the user needs to filter the data using SQL or ORACLE.
I need something like this:
SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE SQL = 'one' AND Oracle = 'two'
Any ideas?
Thank you
Hi Pumkin,
You can't reference an alias directly (except in the ORDER BY clause),
but you can do it indirectly if you use a derived table:
SELECT SQL, Oracle
FROM (SELECT Cod1 AS SQL, Cod2 AS Oracle
FROM YourTable) AS Der
WHERE SQL = 'one'
AND Oracle = 'two'
ORDER BY SQL ASC, Oracle DESC
the select is composed dinamically
Please read the following article very carefully: http://www.sommarskog.se/dynamic_sql.html
--
Hugo Kornelis, SQL Server MVP
Pumkin (Po********@gma il.com) writes: Hello guys, I need help in something as I don't know if it is possible what I want. I have a select like this...
SELECT Cod1 as SQL, Cod2 as Oracle FROM table
and I need to sort by alias SQL or Oracle as the select is composed dinamically so it could be either Cod1 as SQL or Cod2 as SQL and the user needs to filter the data using SQL or ORACLE.
I need something like this:
SELECT Cod1 as SQL, Cod2 as Oracle FROM table WHERE SQL = 'one' AND Oracle = 'two'
I think I would have needed to have more information about where
this query appears.
What you can do is:
SELECT SQL, Oracle
FROM (SELECT Cod1 AS SQL, Cod2 AS Oracle FROM tbl) AS d
WHERE SQL = 'one' AND Oracle = 'two'
The thiing in a parentheses in a derived table. You can use a derived
table for several purposes. Here the purpose is to define queries that
are defined in the rest in the query.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Thank You all... Your idea with the table within the table really
worked.
SELECT SQL, Oracle
FROM (SELECT Cod1 AS SQL, Cod2 AS Oracle FROM tbl) AS d
WHERE SQL = 'one' AND Oracle = 'two'
That is the final select that worked for me. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Amanda |
last post by:
I have tried everything with this!
I get an error stating "Index was outside the bounds of the array"
My code looks like this....
xmlDoc = New XmlDocument()
xmlDoc.Load("xml.doc")
xslDoc = New XslTransform()
|
by: Dave Cooke |
last post by:
Hi I am very new to C. I am trying to figure out how to initialize
a struct in my main program.
The struct is declared in anouther header file like this...
typedef struct ln {
int key;
int data;
struct ln *next;
} listNode, *listNodePtr;
just to test in my main method I tried to initialize the
|
by: Chris |
last post by:
I've lurked around long enough... Time to interract =)
I'm trying to make sense of the following. I can't quite wrap my head
around what this is actually doing:
-------------
typedef enum { DOUBLE_LIST, INT_LIST } DATA_TYPE;
typedef struct {
DATA_TYPE type;
|
by: John Regan |
last post by:
Hello All
I am trying to find the owner of a file or folder on our network (Windows
2000 Server) using VB.Net and/or API. so I can search for Folders that don't
follow our company's specified folder structure and naming conventions and
then send a Net send message to those users telling them to rectify.
The information I want to get is when you select the file/folder and then:
Properties -> Security Tab -> Advanced Button -> Owner Tab ->...
|
by: The Grim Reaper |
last post by:
Dear Gurus...
(Sorry to cross post... but...) I have a dire problem - been working on this
for days now. It's the undocumented API's for NTDLL.dll - namely
NtOpenSection, NtMapViewOfSection, NtUnmapViewOfSection, CloseHandle and
CopyMemory. Code listing 1 shows the existing VB6 code, which works
perfectly. However, on upgrading the code to .NET, I am getting no value
returned to vPhysicalMemory - indicating that the NtOpenSection call...
| |
by: treelife |
last post by:
I'm getting and internal server error when | run the following
mod_python script. I am actually trying to run Django.
Script:
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.write("Under Construction")
|
by: Matthew Warren |
last post by:
I have the following piece of code, taken from a bigger module, that
even as I was writing I _knew_ there were better ways of doing it, using
a parser or somesuch at least, but learning how wasn't as fun as coding
it... And yes alarm bells went off when I found myself typing eval(),
and I'm sure this is an 'unusual' use of for: else: . And I know it's
not very robust. As an ex cuse/planation, this is what happens when you
get an idea in...
|
by: Javad |
last post by:
Hello
I know that I should get the information of windows internet connections by
using "rasapi32.dll" library, and I also have some sample codes, but I can't
make them work. My exact need is to get the "UserName" of a connection. How
is it possible?
plz hlp
thnk u
|
by: =?Utf-8?B?UmljaEI=?= |
last post by:
Can someone confirm if my no spam alias is set up correctly to get answers
to questions. I have been talking to the concierge for over a week to get an
answer to a question. Each time I am told to update my no spam alias and wait
2 business days.
I have paid for MSDN for the last 3 years and don't ask too many questions,
infact I keep being told that the alias expired in May.
I am getting really fed up with waiting 2 business days to...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |