logo
down
shadow

SQL Order By using concat


SQL Order By using concat

By : Clair Wyant
Date : November 22 2020, 10:31 AM
this one helps. I'm concatenating two fields and I only want to order by the second field (p.organizationname). Is that possible? , Use GROUP BY and ORDER BY an aggregate instead of DISTINCT:
code :
SELECT Concat(Concat(f.REFERENCEFILE, ','),p.ORGANIZATIONNAME)
FROM PEOPLE p,FOLDER f,FOLDERPEOPLE fp,folderinfo fi...
GROUP BY Concat(Concat(f.REFERENCEFILE, ','),p.ORGANIZATIONNAME)
Order By MAX(p.ORGANIZATIONNAME)
ID Col1
1  Dog
1  Cat
2  Horse


Share : facebook icon twitter icon
tsql string concat with select and order by does not work with function in order by clause?

tsql string concat with select and order by does not work with function in order by clause?


By : msvb60
Date : March 29 2020, 07:55 AM
wish helps you It would appear that this is a known issue with Aggregate Concatenation Queries.
From the link:
order by within group concat

order by within group concat


By : Humanth
Date : March 29 2020, 07:55 AM
wish helps you I believe you can specify an ORDER BY clause in the GROUP_CONCAT function:
code :
SELECT RunGroupID, GROUP_CONCAT(DNAID, DNBID ORDER BY DNAID, DNBID SEPARATOR '')
Concat of count and group concat and order by

Concat of count and group concat and order by


By : user3501611
Date : March 29 2020, 07:55 AM
Any of those help If I understand correctly, you just want a subquery to calculate the count, before doing the final aggregation:
code :
select id, group_concat(score order by score desc) as scores,
       group_concat(cnt order by score desc) as counts
from (select id, score, count(*) as cnt
      from table t
      group by id, score
     ) t
group by id;
select object_id, group_concat(rating order by rating desc)as ratings,
       group_concat(qty order by rating desc) as qtys
from (select object_id, rating, count(rating) as qty
      from wp_fb_ratings
      group by rating, object_id
     ) t
group by object_id;
Gulp concat in order

Gulp concat in order


By : CSJ Cat
Date : March 29 2020, 07:55 AM
this will help Check out gulp-order
code :
var order = require('gulp-order');

gulp.task('createGlobalScss', function() {
  return gulp.src('sass/**/*.scss')
    .pipe(order([
      'sass/colors.scss',
      'sass/theme.scss',
      'sass/settings.scss',
      'sass/functions.scss',
      'sass/mixins.scss',
      'sass/components/**/settings.scss',
      'sass/theme.scss',
      'sass/components/**/*.scss'
    ], { base: __dirname }))
    .pipe(concat('globalScss.scss'))
    .pipe(gulp.dest('./'));
});
order by charindex >0 and SQL concat

order by charindex >0 and SQL concat


By : user1842767
Date : March 29 2020, 07:55 AM
wish helps you I found the problem when trying to answer @Diado Comment. The parameter ID should be used in SQL context not as a variable in VbScript context. So I have changed the query to this and it works:
code :
sql="select * from customers order by case when charindex( concat(',',id,',') , '" & myString & "' )>0 then 1 else 0 end desc"
Related Posts Related Posts :
  • How to create a database snapshot in SQL Server 2008 R2
  • Query speed and expressions with constant value
  • How to do a complex calculation as this sample
  • Passing a ResultSet into a Postgresql Function
  • Netsuite custom formula field using a CASE statement with multiple WHEN conditions returning "invalid expression&qu
  • Execute query command (dynamic sql) runs faster than ordinary query
  • How to extract only numbered rows from a column
  • INSTEAD OF DELETE trigger (Postgresql)
  • Oracle Apex, when a report with sql is created, how do i get it return after entering in to a text box?
  • Select records based on two tables where one column in one table starts with the records from another tables column usin
  • How to write select using two ids combination in Oracle 11g
  • Frequently use of 'UPDATE STATISTICS WITH FULLSCAN' is normal?
  • need query for this simple pulling data sql server
  • Sql query by using decode to show grades of employee
  • Not a single function error in Oracle
  • Oracle SQL optimizer's behavior when dealing with ORs and row-independent predicates (such as functions returning same v
  • Combining output of two or more select statement
  • Must Declare Scalar Variable Exception
  • Postgres Calculate Difference Using Window Functions
  • SQL Server : unsure how to retrieve selected records
  • SQL unique field: concurrency bugs?
  • Query to get the next identity?
  • SQL Server Adding summing values based on the month
  • Join on month if available else join on latest month
  • How to solve error: ORA-01406 fetched column value was truncated?
  • Selecting Field Multiple Times using OR
  • Which SQL datatype can be used to store mobile numbers in numeric forms, without including characters like brackets and
  • Oracle SQL - "Not a group by expression" after adding CASE statements
  • Runnning total of unique string values in column over days
  • VB.Net to AccessDB by SQL - INSERT INTO with parameters error
  • SQL/Excel/VBA - UPDATE query: 'Syntax Error (missing operator) in query expression'
  • Code to combine two sql queries
  • Setting SQL Date field value based off Week Number and Day Number Field
  • SQL query to find matching records but with differences in case sensitivity?
  • How to sort record inside views in SQL Server 2008
  • How to link the output of teradata sql query to an excel sheet?
  • Matching sets in SQL when cross-referencing
  • error even after following Microsoft format in SQL
  • Increase price by percentage, results rounded
  • Can we Use "Case" in a ColdFusion Query-of-Query
  • displaying 'Active' for a row which has 'A' as value
  • Using pattern search in SQL Server Query
  • SQL - how to group transactions for a certain date pattern?
  • How to Index SQL with multiple AND conditions nested inside OR
  • SQL rank with priority
  • Does BigQuery support SubQueries?
  • Any ideas for persisting H2 Database In-Memory mode transaction?
  • How to improve SQL query performance (correlated subqueries)?
  • Filter repeated columns in Oracle
  • SQL Server join on whichever column has value populated
  • use sql stored procedure to insert data which is returned from a query stored in a table
  • Query not working1
  • SQL - using an alias in a where clause in a subquery
  • How to search for a whole word with special char using oracle contains?
  • Production Perfomance of using SELECT * statements?
  • String concatenation not working as expected in SELECT statement
  • How to detect which stored procedures UPDATE or INSERT into a certain TABLE?
  • Select statement inside CASE - SQL
  • .Net Float error 4 - float(4) = 4.44089209850063E-16
  • How to show as column to recursive rows in a table With SQL Server
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org