Monday, October 22, 2012

yogi_Arrange Data In Queried Table By LastName BirthName (if Available In Ascending Order) And FirstName

Yogi Anand, D.Eng, P.E.      Google Spreadsheet   Post  #819  Oct 22, 2012    www.energyefficientbuild.com.

user Brett Walters said: (http://productforums.google.com/forum/?zx=9jrp4o21m1am#!category-topic/docs/spreadsheets/hUOSt08PMPU)
Add an IF statement within ORDER BY ?
Hi, 

I'm using google spreadsheet to scrape an HTML table and manipulate the data for re-publishing on the web.  Because our initial web form (which produces the HTML table) can't capture the info we need, I have staff manually adding data in a column,  All good up to here.  The new data is maiden name, and with the final output, I'd like it to sort maiden if it exists and then last name.  However, 'ORDER BY' treats the blank cell as a higher sorting cell.

This is what I've tried:

=QUERY(AddBirthName!$A$2:$D$2467;"select A,B,C where D = 1973 ORDER BY (B if B != ''),A";0)

this doesn't work...

Here is a example of the spreadsheet. Looking at the worksheet '1973' I'd like to see the order go 'Harding, Honday, Kimpinger, Korniger' ....


thanks!
Brett
-------------------------------------------------------------------------------------
following is a solution to the problem