Error when trying to lowercase columns in SQL Plus query - sql

OK, I am using SQL Plus and I am trying to view the table and one of the columns I was to view in lower case. This shold be very easy but for some reason it is not work. The code I am using is
SELECT CUSTOMER_NUM, CUSTOMER_ADD (LOWER)CUSTOMER_FIRST, (UPPER)CUSTOMER_LAST
FROM CUSTOMER;
The error I am getting is ORA-00904: "CUSTOMER_LAST": invalid identifier

Try lower(customer_first) and upper(customer_last)

lower and upper is function call, and you also have a missing coma after CUSTOMER_ADD. proper sql should be
SELECT CUSTOMER_NUM, CUSTOMER_ADD, LOWER(CUSTOMER_FIRST), UPPER(CUSTOMER_LAST) FROM CUSTOMER;

Related

Error in use PostGIS SQL function with two select statement

I am new to PostGIS and SQL with a lot of things I need to learn.
I tried this SQL query:
Select ST_AsText(Select line from pathway1f)
I got errors.
Select line from pathway1f
This query works fine; thousands of lines are returned.
I want to decode the query result using ST_AsText().
It seems like I can't use two select statements. What's the correct syntax?
You can use the geometry column name directly
Select ST_AsText(line)
from pathway1f;

Simple mathematical errors in SQL (not a recognized table hints option)

I am having the following error:
is not a recognized table hints option. if it is intended as a parameter to a table valued function, ensure that your database capability is set to 90
from the below code
select*from dbo.customerpurchases
with
(termlystartdate-examdate/365) AS [ID Length]
Any ideas?
Thanks
Try this:
select (termlystartdate-examdate/365) as IdLength, *
from dbo.customerpurchases
It would be better if you specified column names instead of using select *.
select (termlystartdate-examdate)/365 as IdLength
from dbo.customerpurchases

Error show when update using phpmyadmin

When I update a column using phpmyadmin in database with following query
UPDATE members
SET `refered` = (SELECT COUNT (*)
FROM `user_details`
WHERE `user_details.sponser`=`members.username`
)
It show a error message like this
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '*) FROM `user_details` WHERE `user_details.sponser`=`members.username`)' at line 1
What may be reason?
Error is in
COUNT (*)
-----^
Remove the space between COUNT and (*).
Try the below query
UPDATE members SET refered = (SELECT COUNT(*) FROM user_details
WHERE user_details.sponser=members.username)
Does the Select query returns any result. If so what is the result. Looks like all your query is inside '' single quotes that you are using it should be removed. Single quotes need to be removed for example .
UPDATE members
SET refered = (SELECT COUNT (*)
FROM user_details
WHERE user_details.sponser=members.username
)
-- there is not single quotes in the query above. please remove it from yours.
Part of your problem, or maybe the whole problem, is the WHERE clause. You've used backticks for the table name, which is correct (or, at least, it's optional in this case; it's needed if your database name or table name has a MySQL reserved name or is otherwise ambiguous). The problem, though, is that the dot separating the database from the table needs to be outside the backticks. So your WHERE clause should look like this instead:
WHERE `user_details`.`sponser`=`members`.`username`

SQL Queries "00904. 00000 - "%s: invalid identifier"

Hi I have the following code
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON
casestudy_entertainer.entertainer_id
= CASESTUDY_AVAILABILITY.AVAILABILITY_ENTERTAINERID
INNER JOIN casestudy_calendardates ON
CASESTUDY_AVAILABILITY.AVAILIBILITY_CALENDARDATEID
= casestudy_calendardates.calendar_Id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
And I don't seem to be able to figure out what its not liking when I run this.
It gives me the following error
ORA-00904: "CASESTUDY_AVAILIBILITY"."AVAILIBILITY_CALENDARDATEID": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
Error at Line: 7 Column: 4
I do have all the tables in place with all the correct rows.
The only thing is I have no data as of yet, Could this possibly be the issue?
You should try the lower case for the table/column identifiers(like in from/inner join clauses):
SELECT entertainer_id,
entertainer_groupname
FROM casestudy_entertainer
INNER JOIN casestudy_availability ON casestudy_entertainer.entertainer_id = casestudy_availability.availability_entertainerid
INNER JOIN casestudy_calendardates ON casestudy_availability.availibility_calendardateid = casestudy_calendardates.calendar_id
WHERE entertainer_type = '&Entertainer_TYPE'
AND casestudy_calendardates.calendar_date = '&Event_date'
This Error is caused by a special character in one of the columns of the database table. DBA will be able to help you.
You have same tablenames in your tables while left joining.
Change tablename of one , it will work.
no data is not the issue, you won't simply get a null result. ORA-00904 indicates, that you used a column that does not exist or does not comply to the Oracle specification.
Please check for correct naming. You might be better of with shorter names or at least table aliasses to get to code more readable.
Without knowing your table structure I cannot tell you where the error is. do a describe table_name;
It would also help to have the oracle version number SELECT * FROM V$VERSION or SELECT version FROM V$INSTANCE
and your client software you are using
What is interesting, Oracle gives that message not only if the name of the column is bad, but also if the name of the table/alias is bad - not defined alias, twice defined (as mentioned #PrajwalRai), error in the table name.
Old question, but maybe it helps:
sometimes you copy and paste text from a source that has a different character set ...
Type it over in sql-dev for instance and see if the error is gone
I was able to clear this error in an Oracle DB using Oracle SQL Developer by placing strings in single quotes instead of double quotes

Postgresql confuses property as table

I'm trying to use a property that has a .(d0t) in the the propery name, but it seems like postgresql is confused and thinks that i'm trying to access a table property.
Here is the sql query i'm trying to run
select count(metadata.username), metadata.username from appointment join appointment_wrapper a on a.id=appointment_wrapper_id where property='state' and string_value='Kano' and timestamp > '2014-08-01' and timestamp < '2014-11-01' group by metadata.username;
When i run that query it says
ERROR: missing FROM-clause entry for table "metadata"
When i add quotes it says
ERROR: non-integer constant in GROUP BY
Any help on how to solve this?
Thank you
What you're looking for is a "quoted identifier" that you obtain by enclosing your column name in doublequotes to prevent it from being interpreted as a keyword:
SELECT count("metadata.username") from app group by "metadata.username";
Just a reminder that you really, really want to avoid the confusion that having reserved characters in your column or table names bring.