Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sub query substring concatenation issue

Status
Not open for further replies.

louiethebrain

Programmer
Jan 6, 2014
1
US
Hi I’ve been stumped on how to use the substring
In my subqry but i am a little stumped
Could someone lend a hand and explain the
Err in my ways please..

select tagname, padname = 1, datetime, (select value from analoghistory where tagname = 'tata' + substring(a.tagname, 6, 2) + 'lastpart'
and datetime = a.datetime) as value
from DiscreteHistory a
where tagname in ('Tag name here')
and datetime >= {ts '2017-11-01 07:45:00'}
and datetime <= {ts '2017-11-10 15:48:00'}
and wwresolution = 60000
and value = 1
order by tagname, datetime

Thanks
 
what error does the above give you?
Or does not give any error but does not do what you expect? and on this case what were you expecting to happen?

And do not use SQL server reserved words for column names - it is quite bad practice and columns like "datetime" do not express the meaning of the column itself

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top