I am currently trying to just get a certain format of a bill, but I don't know how to select a custom test.
For Example, I Select something like this
Name Age Birthday Gender
Jonas 26 01.01.2000 Boy
The Boy in this one is no Information that is in a table but manually made and I don't know how to do that. Every other Information is from a Table (that was easy).
Summary: How do I manually write a text into a Select?
select name, age, birthday, 'Boy' as gender
from your_table ---------------
like this!
I am trying to run few queries on Oracle SQL developer
e.g
Select name AS CandidateName, age AS CandidateAge
from tbl_candidate_details
order by candidate_id desc
But In the result I am getting the column names as "CANDIDATENAME" AND "CANDIDATEAGE".
Is there a way where I can get this as camelcase characters what I have given in the select statement("CandidateName" and "CandidateAge") ?
If the column aliases are wrapped in double-quotes, SQL Developer will use those exact values as the column names in the query results:
SELECT name AS "CandidateName", age AS "CandidateAge"
FROM tbl_candidate_details
ORDER BY candidate_id DESC;
Otherwise, the column names in the query results are always displayed in upper case
SQL is case insensitive and the SQL standard requires to fold all un-quoted identifiers to uppercase. If you want to preserve the case of your identifiers you need to quote them:
Select name AS "CandidateName",
age AS "CandidateAge"
from tbl_candidate_details
order by candidate_id desc
I am using vs 2010 and want to perform a query on sql server database. But i have a problem i want to retrieves a row on the basis of name which i want to retrieves it using second character of name that is i don't know the first character that is for example the name is nik as i enter i it will retrives a record which having nik as value of name column.
Can any one guided me...I know following query what things i have to modified in it.
select * from table1 where name like '"& n % &"'
for example the name is nik as I enter i it will retrives a record which having nik as value of name column
try
select * from table1 where name like '_i%'
TSQL Like
I have one table named tblalias.which is having two columns cid, description
cid description
1 Employee
2 Join Date
3 Retire Date
Like this three record is present
Now I have another table tblemployee. I want to write a query for tblemployee to get record but alias name for that query I want should come from tblalias
select nama as Employee,
joindate as "Join Date",
retiredate as "Retire Date"
from tblemployee
If I change value is tblalias table to my select query should return new value as alias is it possible if yes how please help me
The only way to do this is with dynamic SQL. First fetch the alias names then build the final SQL and execute it.
There is no way doing this with a single "hardcoded" statement.
If you want spaces in names you should quote them. (spaces in names is generally a bad Idea, but that's another matter)
I have a query that pulls the phone extension and the full name of a person from my phone system import, and splits the full name into a First and Last name. It is working great for spliting the name up but if I try to sort by either name I get a Data Tyep Mismatch Error.
Here is the SQL Code.
SELECT ExportG3R.Extension,
Left([ExportG3R.name],InStr([ExportG3R.name],",")-1) AS LastName,
Trim(Mid([ExportG3R.name],InStr([ExportG3R.name],",")+1,Len([ExportG3R.name])-InStr([ExportG3R.name],","))) AS FirstName
FROM ExportG3R
ORDER BY ExportG3R.Extension;
Any ideas on how to get this working?
I created a ExportG3R table with text fields for Extension and name. Your query worked with name values like "Litzner, Mike". However, a name value which doesn't include a comma, such as "Litzner Mike", gave me #Error for LastName and "Litzner Mike" for FirstName. And if name is Null, it gives me #Error for both. Neither of those was a deal-breaker for SELECT until I tried to sort on LastName and/or FirstName. When attempting those sorts, the Access 2003 db engine responded "Invalid procedure call", which is not the same error message you're getting.
So, although I'm not certain my situation exactly matches yours, I'll suggest you try your query with a WHERE clause to return only rows which have non-Null name values and also include a comma.
SELECT
e.Extension,
Left(e.[name],InStr(e.[name],",")-1) AS LastName,
Trim(Mid(e.[name],InStr(e.[name],",")+1,Len(e.[name])-InStr(e.[name],","))) AS FirstName
FROM ExportG3R AS e
WHERE e.name Like "*,*"
ORDER BY ORDER BY 2,3;
Another concern is that name is a reserved word. When creating that table in design view with Access 2007, gave me a warning about that field name. Try creating a throw-away table in Design View and read the help it offers when it gives you a warning about name. If at all possible, change it to something which isn't a reserved word ... FullName perhaps.
Finally I think this would be simpler if the name field were split into two fields in the table itself. Storing names as "Last, First" combines 2 attributes in one field. So when you need either of them, you must split them out. It's easier to store them separately, then concatenate them whenever you need them as "Last, First":
SELECT LastName & ", " & FirstName AS FullName
you could wrap it in a sub query;
SELECT extension,lastname,firstname
FROM (
SELECT ExportG3R.Extension,
Left([ExportG3R.name],InStr([ExportG3R.name],",")-1) AS LastName,
Trim(Mid([ExportG3R.name],InStr([ExportG3R.name],",")+1,
Len([ExportG3R.name])-InStr([ExportG3R.name],","))) AS FirstName
FROM ExportG3R
) order by firstname