| Author |
Topic |
|
jamilahmed
Starting Member
18 Posts |
Posted - 2009-04-07 : 07:56:41
|
| Hallo, I have the following select statement and trying to order it by oracle_no. However, when I execute the query it doesnt order by oracle_no. any ideas??SELECT TOP (100) PERCENT gprdsql.TblQuarPay.prac_no, gprdsql.TblQuarPay.prac_eid, gprdsql.TblQuarPay.AmounttobePaid, gprdsql.TblPracDetails.pay_method, gprdsql.TblPracDetails.pay_acc_num, gprdsql.TblPracDetails.pay_sort_code, gprdsql.TblPracDetails.post_code, 'GPRD' + ' ' + gprdsql.TblPracDetails.pay_method AS Paygroup, gprdsql.TblOracleNos.Oracle_no, 'GPRD' AS Source, 'GBP' AS Currency, '0' AS Tax_Percentage, 'abc' AS Liability_account, 'xyz' AS Expense_acc, 'GPRD' + ' ' + 'Qtr' + ' ' + 'Payment ' + '0' + RIGHT(STR(dbo.Qrymthyr.Month_no), 1) + RIGHT(STR(dbo.Qrymthyr.Year_no), 2) AS DescriptionFROM gprdsql.TblQuarPay LEFT OUTER JOIN gprdsql.TblPracDetails ON gprdsql.TblQuarPay.prac_no = gprdsql.TblPracDetails.prac_no AND gprdsql.TblQuarPay.prac_eid = gprdsql.TblPracDetails.prac_eid LEFT OUTER JOIN gprdsql.TblOracleNos ON gprdsql.TblPracDetails.pay_method = gprdsql.TblOracleNos.Pay_method AND gprdsql.TblPracDetails.prac_eid = gprdsql.TblOracleNos.Prac_eid CROSS JOIN dbo.QrymthyrORDER BY gprdsql.TblOracleNos.Oracle_noThanks for any help |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-07 : 07:59:08
|
| whats the output ? |
 |
|
|
jamilahmed
Starting Member
18 Posts |
Posted - 2009-04-07 : 08:12:15
|
| It orders by gprdsql.TblQuarPay.prac_no instead of gprdsql.TblOracleNos.Oracle_no. |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 08:12:45
|
Works for meSELECT TOP (100) PERCENT qp.prac_no, qp.prac_eid, qp.AmounttobePaid, pd.pay_method, pd.pay_acc_num, pd.pay_sort_code, pd.post_code, 'GPRD' + ' ' + pd.pay_method AS Paygroup, [on].Oracle_no, 'GPRD' AS Source, 'GBP' AS Currency, '0' AS Tax_Percentage, 'abc' AS Liability_account, 'xyz' AS Expense_acc, 'GPRD Qtr Payment 0' + RIGHT(STR(q.Month_no), 1) + RIGHT(STR(q.Year_no), 2) AS [Description]FROM gprdsql.TblQuarPay AS qpCROSS JOIN dbo.Qrymthyr AS qLEFT JOIN gprdsql.TblPracDetails AS pd ON pd.prac_no = qp.prac_no AND pd.prac_eid = qp.prac_eidLEFT JOIN gprdsql.TblOracleNos AS [on] ON [on].Pay_method = pd.pay_method AND [on].Prac_eid = pd.prac_eidORDER BY [on].Oracle_no E 12°55'05.63"N 56°04'39.26" |
 |
|
|
jamilahmed
Starting Member
18 Posts |
Posted - 2009-04-07 : 08:22:34
|
| whats the problem then?any ideas what might causing the problem. Settings or anything particular with the view? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 08:24:56
|
quote: Originally posted by jamilahmed whats the problem then?
We can't tell since we have no access to source data. E 12°55'05.63"N 56°04'39.26" |
 |
|
|
jamilahmed
Starting Member
18 Posts |
Posted - 2009-04-07 : 10:19:59
|
| Ok, this is how it sorts it 1271601711773177417751776177717781779178017821783178417851786178717881789179017911792179317951796179718418451847As you noticed it reads 127, 160, 171 then 1773 instead of 184. Also note, oracle_no has been set as varchar. This might highlight something |
 |
|
|
sakets_2000
Master Smack Fu Yak Hacker
1472 Posts |
Posted - 2009-04-07 : 10:32:34
|
| order by convert(int,gprdsql.TblOracleNos.Oracle_no) |
 |
|
|
yosiasz
Master Smack Fu Yak Hacker
1635 Posts |
Posted - 2009-04-07 : 10:50:09
|
| this is what I have used. it helped out a lot in the situation you are mentioninghttp://oreilly.com/catalog/transqlcook/chapter/ch08.html<><><><><><><><><><><><><><><><><><><><><><><><><>If you don't have the passion to help people, you have no passion |
 |
|
|
jamilahmed
Starting Member
18 Posts |
Posted - 2009-04-07 : 10:56:47
|
| Thank you very much. Done the magic |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-04-07 : 11:22:16
|
| why is Oracle_no varchar in first place if it stores only numeric data? |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 13:13:29
|
ORDER BY LEN([on].Oracle_no), [on].Oracle_no E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|