| Author |
Topic |
|
deathrone
Starting Member
15 Posts |
Posted - 2012-08-17 : 06:44:44
|
| Hello everybody,I'm new user here. I've just finish my first degree of econometrics and started my career as analysit in risk management in Poland. I donno SQL in practice so now i would like to answer ya little question:f.x. We've got:SELECT count(blabla) sumaFROM jabadabuGROUP BY trololoand the result is:suma456465454646216311321321etc.how to make the result like this:suma4 564 65454 646216 311321 321etc.??trololoolo |
|
|
jackv
Master Smack Fu Yak Hacker
2179 Posts |
Posted - 2012-08-17 : 09:47:44
|
| generally , it is better to do this sort of formatting at the presentation layer . But if you must, this is one method.declare @num INTset @num = 4564654select replace(replace(convert(varchar,cast(@num as money),1), '.00',''),',',' ') Jack Vamvas--------------------http://www.sqlserver-dba.com |
 |
|
|
deathrone
Starting Member
15 Posts |
Posted - 2012-08-20 : 03:29:58
|
| thx man! i dont understand that perfectly but i have a lot of fuckin time to learn, cuz i will be as good as ya some day... ;)can ya tell me one thing more: how to choose one record, with maximum date. I wrote this:select * from tabelawhere date=max(date)but this doesn't work :(trololoolo |
 |
|
|
Abu-Dina
Posting Yak Master
206 Posts |
Posted - 2012-08-20 : 04:28:54
|
| deathrone, some friendly advice. Please don't use vulgar language. |
 |
|
|
Abu-Dina
Posting Yak Master
206 Posts |
|
|
deathrone
Starting Member
15 Posts |
Posted - 2012-08-20 : 04:47:18
|
| yee i tried to use limit/top/rownum but it doens't work too :(select * from tabelawhere rownum <2order by dateSyntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, '.', /, <, <=, <>, =, >, >=, ?, AND, CONTAINS, EQ, EQT, GE, GET, GT, GTT, LE, LET, LIKE, LT, LTT, NE, NET, OR, ^=, |, ||, ~=. :(trololoolo |
 |
|
|
Abu-Dina
Posting Yak Master
206 Posts |
Posted - 2012-08-20 : 04:50:40
|
Something like this:select a.* from tabela as awhere a.date= (select max(date) from tabela as b where a.ID = b.ID) |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-08-20 : 05:11:10
|
deathrone, are you using MS SQL Server ?FYI, SQLTeam.com is on Microsoft SQL Server. For other DB systems, try dbforums.com KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
deathrone
Starting Member
15 Posts |
Posted - 2012-08-20 : 05:13:01
|
| yup Abu-Dina, that idea is logic and shou be ok but the SAS compilator says now:ERROR 76-322: Syntax error, statement will be ignored.Khtan: I use oracle database i think, cuz i'm writtin it in SAS, proc SQL.trololoolo |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
deathrone
Starting Member
15 Posts |
Posted - 2012-08-20 : 05:28:41
|
| ok, bro. That forum is nice.trololoolo |
 |
|
|
|
|
|