Including an Expression in SQL Code with Columns from a Table
The code under MY CODE will not work. Getting error saying 00922-from keyword not found where expected..
In the examples I looked up, the months_between function was written as a select statement like:
Select
months_between (sysdate,me607.mbr_dob) / 12 as date
from mbr_exp me607
Can anyone help me with the syntax I need to include this with my SQL code as below?
Thanks..
MY CODE:
Select
me607.mbr_dob,
months_between (sysdate,me607.mbr_dob) / 12 as date
from mbr_exp me607
-date- is an oracle keyword and cannot be used as a column name
SQL> select sysdate as date from dual
select sysdate as date from dual
Error at line 1
ORA-00923: FROM keyword not found where expectedeither do
select sysdate as "date" from dualor use a diffent colum name.
Similar Messages
-
Problem creating a datablock with columns from 2 tables...
Hello guys, i have a problem in creating a datablock with columns from 2 different tables. I try to create the datalock manually and in the Query Data Source Type Property i choose FROM clause query, and in the query data source name property i type my sql statement with the columns i want to display.After that i place the items that the datablock will contain , manually from the painter. However , when i run the application, the datablock doesn't display the items from the database. Am i doing something wrong?
Thanx in advance,
Regards,
Bill.Never mind Peter, I found the error. I forgot to make execute_query for the datablock, so this was the reason why the items weren't displayed to me.
Thanx anyway a lot for your advices and your time you spent ! -
Update data provider queryspecification wiith columns from multiple tables
Hi
I have scenario like I need updated a queryspecificaiton with columns from multiple tables
1. Ex:
<bOQuery name="Query">
<resultObjects identifier="DS0.DO1" name="A$Application_ID"/>
<resultObjects identifier="DS0.DO2" name="A$Column_Name"/>
A$Application_ID is from Table A and A$Column_Name from table B
The query is not adding to dataprovier when I am trying to updated from REST API.
Please help me.
Thanks
KalyanHave a look at the Business Intelligence platform RESTful Web Service Developer Guide, section 3.4.7 (p. 197) - Report structure: getting and updating the structure (specifications) of a report, may be a good place to start(?). Also see KBA 1952419 - How to update the properties of a web intelligence report using RESTful web service SDK .
- Ludek
Senior Support Engineer AGS Product Support, Global Support Center Canada
Follow us on Twitter -
Including column from fact table reduces number of rows returned
Hello
I am facing this issue where in a report I select 5 columns from a fact table. Out of these five columns one of the column is "Amount" for which the aggregation rule is defined as Sum in RPD.
When I include these five column and filter results based on some criterion , I get all the rows (three rows) that satisfy the criterion. No I add a sixth column to my report and suddenly I only see one row returned by my report. Addition of this sixth column does not affect the criterion as the criterion is not based on this column. But this sixth column is a calculated column.
I tried different things but because the report was just getting columns from one table (fact) and suddenly inclusion of one column leads to reduction in number of rows , I was unable to find any reason why would that happen.
So I thought that some one in community may know that in what scenario this happens.
ThanksAre there any repeated values? I'm wondering if what you're seeing is actually suppression of repetition in the results. Edit the analysis, go to the criteria tab, click column properties, go to the Column Format tab, and change the setting for value suppression from 'Suppress" to "Repeat". Repeat for each of your 6 columns and check the outcome.
Otherwise, I would try testing with other calculations and also bring in some columns from dimension tables to see how this affects the result. You should be able to come up with a case-by-case scenario to work out exactly what causes the rows to be suppressed which will get us one step to closer to working out why the rows get suppressed.
Thanks,
George -
Combining the same column from 2 tables with distinct result.
I have 2 tables with identical name columns. One is current people and the other is historical people. I want a select that returns any name that is in either table. I want each name listed only once. I want to see 1 entry for each name if it is in the current table, the historical table, or both tables. I can easily do a select distinct on each table but how do I join the queries to get 1 result set with no duplicates? The name column is not a key field and I don't want any other columns from either table.
Just a simple UNION:
select name
from current
union
select name
from historical; -
Selecting columns from two table is slow but same
I am selecting 27 columns from two tables
which running for more than 30 minutes. but
if I select count(*) with the same query
except the columns it is coming in seconds.
Where is the error?If you post
1) The table definitions for the underlying tables
2) The indexes that are on the tables
3) The two SQL statements you're running
4) The explain plan for both statements
we can probably be of some assistance.
My guess is that the count(*) is able to return much more quickly because the optimizer is able to use a significantly faster query plan that is based on an index which the longer-running query cannot utilize. Without the information I've requested, though, it's hard to do more than speculate.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Work with data from a table of another SAP R/3 system
Hi,
I want to work with data from a table of another system. I know there's a function called 'RFC_READ_TABLE' but I don't know really how it works. What I want to do is to get data from that system and pass it to the one where I'm working in order I can continue working with this data in the report.
Besides, I'd like to select only the records that have some conditions.
I'd appreciate if someone could tell how to do it, whether with FM 'RFC_READ_TABLE' or in another way.
Thanks in advance,
Gerard
P.S: The systems are already connected in SM59Yes, you can use RFC_read_table .You can pass the number of columns but I recommend you to bring all results in your internal table after that you can filter the records. Most of the time I have notice when you make RFC call with this FM to another system it works but it may also happen that other system controlling authorization and then it might give you nothing. As I face this problem on my last Project.
Hope thisll give you idea!!
<b>P.S award the points.</b>
Good luck
Thanks
Saquib Khan
"Some are wise and some are otherwise" -
How to delete a column from the table control in module pool?
Hi,
can any one please tell How to delete a column from the table control in module pool?
thanks in advance
warm regards
HareeshKumar Nhi hareesh,
I think it is better to hide it.
How to hide: You can check this link
Dynamic Hide column in table control -
How to remove a column from alv table
Hi All
How to remove a specific column from alv table.?
Thanks & Regards
SUNFor delete u can follow the above post..
Fo making invisible :
data m_col type ref to cl_salv_wd_column.
m_col = alv_mode->IF_SALV_WD_COLUMN_SETTINGS->GET_COLUMN (' col1' ).
m_col->SET_VISIBILITY( '01' ). -
How can I select columns from a table EMP, using Select statement?.
Hi Friends,
How can I select columns from a table EMP?.
I want to select columns of EMP table, using select statement.
Please reply me urgently.
ShahzadSomething like this:
scott@DBA> select empno,ename,job from emp;
EMPNO ENAME JOB
7369 SMITH CLERK
7499 ALLEN SALESMAN
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
7788 SCOTT ANALYST
7839 KING PRESIDENT
7844 TURNER SALESMAN
7876 ADAMS CLERK
7900 JAMES CLERK
7902 FORD ANALYST
7934 MILLER CLERK
14 rows selected.Check the documentation:
http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_10002.htm#sthref9697
Message was edited by:
Delfino Nunez -
Delete a column from the table
Hi.
I would like to delete a column from a table. I want to drop the table and recreate it later. But this table has a primary key which
is a foreign key of other tables. So after I recreate the table I must recover the relationship of this table and other tables.
How do I get the information about the primary key of this table as a foreign key of other tables from data dictionary?
Thanks in advance
nullFor ur query the reply whay u have got is correct one. For further quries similar to one u had u can download a tool named TOAD (Tools for Oracle Application Developer) from quest site (www.quest.com). Install it a proceed.
Do let me know how and what u feek about TOAD. -
Columns from different tables displayed in an ADF table format
I have a many to one relationship between 2 tables (checklist -> subcontract). I would like to display columns from each table on a web page in an ADF Read Only Table format. I created a method that returns the data I need from the tables. When I drag that method over to my page JDev I'm only allowed to select columns from either the checklist table OR the subcontract table. I need one column from the subcontract table and several columns from the checklist table. I'm using JDev 10.1.3.2 and an Oracle 11g database. Thank you in advance.
-WadeThank you for your response. I ended up creating a new getter in the Checklist table which refers to the column in the Subcontract table. Then I was able to create a table column for that returned value.
Thanks again!
-W -
SQL update one column from another column
I'm looking for a way to update a SQL column with a portion
of info from another column in the same table.
example of a sql command
UPDATE table1
SET table1.columnname1 = table1.columnname2
FROM table
WHERE blah blah blah
Here's the thing... I only need a portion of the data found
in the source column. I'm not sure how I would do this then.
for example, the database has countries and states combined
into one column like this 'US-DC', 'US-CA', US-FL', etc. I want to
separate these into two columns, a country column and a state
column.... and I dont want to go though all the results and do this
line by line. How would I write the SQL command so that it puts
just the country in the country column, and puts just the state in
the state column, and it omits the dash all together.
any ideas?It depends. Are you using PHP and mySQL or ASP and SQL?
If you are using mysql and PHP you could use the following
code to loop through all records in your datatbase.
$sql="SELECT * FROM tablename"; //SET tablename to the name
of your database table.
$result=mysql_query($sql)or die(mysql_error(). " - $sql");
for($x = 0; $row=mysql_fetch_assoc($result); $x++){
//set up the variables from the table
$ID=$row['ID']; //this is the primary key
$var1=$row['contrystatecolumn']; //this is the name of the
column which holds the country-state
$var2=explode("-", $var1); //now we explode the string to get
the country and the state seperated and place the results into an
array
$country=$var2[0]; //this is the first piece of the exploded
string in the array
$state=$var2[1]; //this is the second piece of the exploded
string in the array
//now we update the database record with the new information
//remember to replace the tablename with your actual table
name and the columns country and state with the acutal names of
your columns in your table
$sql2="UPDATE tablename SET country='$country'.
state='$state' WHERE ID='$ID'";
$result2=mysql_query($sql2)or die(mysql_error() . " -
$sql2");
This code will loop through every record in your table and do
what you want very quickly.
Hope this helps
Stan Forrest
Senior Web Developer
ATG Internet -
Execute SQL Task with Parameter - from DB2 to SQL Server
I am pulling data from DB2 to SQL Server.
1st Execute SQL task runs the following against DB2:
SELECT TIMESTAMP(CHAR(CURRENT_DATE - (DAY(CURRENT_DATE)-1) DAYS - 1 MONTH)) as START_MONTH
FROM SYSIBM.SYSDUMMY1;
I'm storing it as a Result Set.
Next I have a Data Flow Task. This pulls data from DB2 where the date matches the parameter.
FROM SCHEMA.TABLE t
WHERE DATE_TIME_COLUMN= ?
This works fine. Guessing, because the parameter source is DB2 and the Data Flow source is DB2.
The problem is, I want to remove existing data for the same date in the SQL table. IE, if I'm pulling March 2014 data from DB2, I want to be sure there is no March 2014 data in the SQL table. The main use is for re-runs.
So, I added another Execute SQL task after the first one that assigns the variable, and before the Data Flow Task. This runs the following statement against SQL Server:
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= ?
The package fails at the new Execute SQL Task with the following error message:
Error: 0xC002F210 at Execute SQL Task, Execute SQL Task: Executing the query "DELETE FROM
SBO.dbo.tblHE_MSP_FEE_BUCKETS
WHERE T..." failed with the following error: "Parameter name is unrecognized.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
correctly.
Task failed: Execute SQL Task
SSIS package "Load_MSP_Fee_Buckets_SQL.dtsx" finished: Success.
The program '[14240] Load_MSP_Fee_Buckets_SQL.dtsx: DTS' has exited with code 0 (0x0).
I am assuming this is something to do with the Parameter source being DB2, and trying to use against SQL?
Any suggestions on how to make this work??
Thanks,
-Al HParameter name is unrecognized
is the key, how come DB2 is related if it runs against SQL Server
What I think is happening you do not use the OLEDB connection to SQL Server.
Likewise, if it is ADO then the query needs to be
DELETE FROM
database.dbo.table
WHERE DATE_TIME_FIELD >= @MyDate
Arthur My Blog -
Count(*) , group by with multiple columns from multiple tables involved
Hi all,
I am relatively new to SQL.
Currently I have these few requirements, to display quite a number of fields from 3 tables for display of report.
In my query I need to:
1.) count(*)
2.) select quite a number of fields from table 1,2,3
However when count(*) is used, grouped by has to be used to.
How do I actually use group by with so many columns to be selected?
I have actually used the query below, but the count(*) returns 1, the correct output should be 3 instead.
select count(*), table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
from table1, table2, table3
where
<conditions>........................
group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
I know this group by statement looks very unrefined. How can I select multiple fields from different tables, and yet get the count(*) correctly?
Thank you so much for your time.Hmm yes it actually does return count as 1 for each row. But there are 3 rows returned. E.g.
ctr table1.col1 table1.col2 ..........
1 value1 value1
1 value2 value3
1 value3 value4
If I put the count(*) outside, it returns 3 , the correct output
ctr
3
select count(*) from
select table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
from table1, table2, table3
where
<conditions>
group by table1.col1, table1.col2, table1.col3, table2.col3, table2.col4, table2.col6, table3.col1, table3.col4, table3.col5
Thus I was wondering if it was the group by of multiple colns that resulted in the count stucked at value 1.
Maybe you are looking for
-
Created Adobe Portfolio - now all pdf reload with open
Help! I needed to email 70 pdfs. Instead of putting them all into one large pdf, I used the 'suggestion' in the new Macintosh Acrobat Pro 9 that I use a Pdf Portfolio. ( I used three Portfolios, then emailed them using the "email this portfolio" butt
-
Help with Account Removal from Skype Directory
To whom it may concern, I need help with removing my Skype account from the Skype Directory. According to this webpage: https://support.skype.com/en/faq/FA142/can-i-delete-my-skype-account, only someone from Skype Customer Service can remove my acco
-
JMS Appender in log4j.properties ??
Hie Experts, I have setup a logging mechanism to log messages asynchronously using JMS queue. Currently, I am doing this as a call to a method. Inside the method, I am - creating a JNDI context, - retrieve queue connection factory, - create a queue s
-
I can't find any pre 2.0 updates for the ipod touch
I had to restore my ipod touch because of problems and now it's back to cutting songs off randomly. I want to update but I don't want to pay $10 for 2.0. I looked everywhere on my itunes and on apple's website but found nothing. Any help would be app
-
Access Violation in module RunPci.dll
Getting error message of "Access violation at address 0146139C in module 'RunPci.dll'. Read of address 00000000." This happens when trying to load/run the "Utility" setup on the MSI Utility&Drivers CD. Fuzzy Logic III not loading and bootup/bootdown