I've finally gotten my hands on MS Access 2010, and I'm unioning some tables.
I'd like to output that union to a (static) table, but if I select the Make Table option it wipes the union query you've just written, and vice versa.
This is trivial to do in SQL (Select * into A from( Select tbl1.col1 from tbl1 UNION Select tbl2.col2 from tbl2 or somethign similar)
But is it possible to do just by pressing buttons?
No, it is not possible with pressing buttons. Use sql view of the query design window.
Related
I use the WITH clause in Oracle SQL lots of times and knowing that more than 90% of the time, it performs faster, but since I am working on the Peoplesoft application, so I just wonder is there a way to use the WITH Clause in Peoplesoft Query Manager, too?
Put your SQL inside a Record View. Grant Query Tree security to the record view. SELECT * from your view via PS Query.
From memory, I seem to have also had some success wrapping the query as an inline view inside the Record View.
e.g. Record View SQL:
SELECT * FROM
(
<INSERT Common Table Expression here>
)
Using example Common Table Expression
with MYCTE AS (SELECT 1 as fake FROM DUAL) SELECT fake FROM MYCTE WHERE fake = 1
That would then become
SELECT * FROM
(
with MYCTE AS (SELECT 1 as fake FROM DUAL) SELECT fake FROM MYCTE WHERE fake = 1
)
Naturally, PeopleTools Application Designer will reformat the SQL as it sees fit when you save the definition.
I am trying to fetch set of records from the database part by part.
I tried to use Limit and fetch but it seems like it does not working with oracle 11g. Is there any alternative solution to do this. I have tried many in google results but nothing is working properly.
You can use this query and do what u want.
SELECT A.*
FROM (SELECT A.*, ROWNUM ROWNUMBER
FROM Table1 T
WHERE ROWNUM <= TO) T
WHERE ROWNUMBER > FROM;
FROM is from which number and TO is to which number
A Sound application is based on sound design. Kindly check if you are trying to achieve a procedural requirement using an SQL. If yes, it is better to use PL/SQL instead of SQL.
Create a cursor using the required SQL without any limits.
Create a type of associative array to hold the batch records.
Create an associative array using the type created above
Open and loop the cursor.
FETCH created_cursor BULK COLLECT INTO created_associated_array LIMIT ;
Hope this helps.
To select many strings from dual as one column. I have tried the solution below and i can live with it, its relatively easy with PL/SQL macros to add "select from dual". I'm wondering is there any other way to achive this?
select 'AAA' as code
from dual
union all
select 'ABQ'
from dual
union all
select 'ACA'
from dual
union all
from dual
For a single column query there is. You need a database type that is a table of VARCHAR2, and some always exist in oracle including:
SYS.KU$_VCNT
SYS.DBMS_DEBUG_VC2COLL
(and of course you could create your own if you prefer).
Then you can query like this:
select * from table (SYS.KU$_VCNT ('AAA','ABQ','ACA'));
For a query with more than one column, you would need to create a type specifically for that query, which isn't such a useful option. But just for completeness this is how you could do it:
create type my_obj_t as object(n number, d date, c varchar2(100));
create type my_tab_t as table of my_obj_t;
select * from table (my_tab_t(my_obj_t(1,sysdate,'aaa'),
my_obj_t(2,date '2014-12-31','bbb'),
my_obj_t(3,sysdate+2,'bbb')));
So at the moment I am building a Advanced Search in .NET, and getting the results is just proving a bit slow so was looking at creating indexes on the tables.
I.e went to tables and define full text index.
So now I have my catalog with the 5 tables and selected columns.
But I cant see how this catalog actually joins these tables ?
I.e. in my "slow" stored procedure I could have
select *
from table1
inner join table2 ON table1.id = table2.linkedID
etc for other tables ?
and now I guess I can go
select * from catalogName
but how does catalogName know what columns to join for the inner join etc
You don't query the fultext catalog directly, you use the fulltext functions in your query, like CONTAINS, CONTAINSTABLE, FREETEXT and FREETEXTTABLE:
SELECT field, field, field
FROM table
WHERE CONTAINS(field, 'some text');
Full text has nothing to do with joining tables and if your query is slow because you join 5 tables then FT is unlikely to help at all.
I have a simple table of data that needs to be transposed from row data into column data. For example let me create a simple employee table:
I need to create a side-by-side comparison report structured like this using the above sql table:
Can someone show me the sql code using the sample table above? Or can it be done automatically using a built in ASP.net or DevExpress control?
Your feedback is always appreciated!
Thanks!
What you're looking for is a "pivot" function.
You can do them by hand inside of SQL, but it also looks like devexpress has a control for this...
http://www.devexpress.com/Products/NET/Controls/ASP/Pivot_Grid/
-- EDIT --
Like the commenter above posted, here's an introduction to the pivot function in SQL Server... What makes this tricky, is that unless you know exactly what values will comprise your columns, you'll have to use dynamic SQL to build the pivot.
Because it can be a little tricky to do in SQL, I'd try to stick to DevExpress since you already have it...
I think that if you were to add multiple data points to your pivot grid, that it would look like what you're expecting. Here's a screen shot from DevExpress that resembles what you're looking for...
Here's the page that shows this technique... In your case, instead of a row grouping, you could just do a "grand total", and then hide that column...
There it´s using SQL:
WITH FieldValueCte AS(
SELECT Name,
'Department' Field,
Department Value
FROM Table1 UNION ALL
SELECT Name,
'Sex' Field,
Sex Value
FROM Table1 UNION ALL
SELECT Name,
'HireDate' Field,
HireDate Value
FROM Table1 UNION ALL
SELECT Name,
'Salary' Field,
Salary Value
FROM Table1 UNION ALL
SELECT Name,
'Comments' Field,
Comments Value
FROM Table1)
SELECT [Field], [John Doe], [Jane Smith], [Peter Parker], [Jessica James]
FROM
(SELECT Field, Name, Value
FROM FieldValueCte) AS SourceTable
PIVOT
(
MIN(Value)
FOR Name IN ([John Doe], [Jane Smith], [Peter Parker], [Jessica James])
) AS PivotTable;
The solution is provided here
http://www.aspsnippets.com/Articles/Rotate-ASPNet-GridView---Convert-GridView-Columns-to-Rows-and-Rows-to-Columns.aspx