sql

Representing ecommerce products and variations cleanly in the database

I have an ecommerce store that I am building. I am using Rails/ActiveRecord, but that really isn't necessary to answer this question (however, if you are familiar with those things, please feel free to answer in terms of Rails/AR). One of the store's requirements is that it needs to represent two types of products: Simple products - t...

SQL Server: Can I Comma Delimit Multiple Rows Into One Column?

Creating Comma Separated Lists In SQL Hi All, I am attempting to merge something like this in my SQL Server database: [TicketID], [Person] T0001 Alice T0001 Bob T0002 Catherine T0002 Doug T0003 Elaine Into this: [TicketID], [People] T0001 Alice, Bob T0002 Catherine, Doug T0003 ...

MySQL: Last 10 entries per user?

I have a table storing transactional data for users. To find a users rating you take the average score of the last 10 entries for that user. Is there a way to get that with SQL? I need to be able to work it out for a single user given their ID. And to get a list of all users ordered by their score. Currently I'm working it out outside ...

Convert "\n" to actual newline in SQL Server

I have a bunch of varchar(255) and varchar(max) fields in a table in MS SQL Server. These are generally formatted messages (email and other). Most of the fields have the actual characters "\n", but actually need a newline character. I don't need to worry about new data going forward, but don't know how to fix the stuff that's currently ...

Stored Procedure returning Multiple resultset

Hi One Stored procedure returning multiple result sets and I need only the last result set, How do I achieve this without changing original procedure. am using the last reulst set in further processing in other Stored procedure. ...

is there a common example SQL schema that shows all the major cardinalities?

I'm writing up documentation for a tool that works with SQL schemas. It would make sense for the documentation to use a common example schema rather than making up a new one. Any recommendations for one that's already defined somewhere? Ideally it would come from a problem domain most readers are already familiar with; have an examp...

Small table with Link to more information

This may be a newbie question, But let's say I have a database table w/ 10 fields. However, on the first screen I want a small 4-5 field table displaying corresponding data. But the first field, let's call it ID, I want to be linkable to a full table that will display complete details about that, all 10 db fields. What would the codi...

Error? Shared Memory Provider: No process is on the other end of the pipe

I have a site which has been running perfectly but I have just moved it from Win2003 IIS6 SQLExpress to Win2008 IIS7 on full SQL and randomly the site is going down and all I keep getting is this error? Shared Memory Provider: No process is on the other end of the pipe. Anyone have any ideas on what might be causing it? ...

Database Query Help required in MySQL

I am looking for help in writing a query of retrieving the values from 2 tables in MySQL. The scenario is Table A ID Name Marks =================== 23 John 67 45 Mark 45 12 Ram 87 Table B has the following Structure ID Name Evaluation Marks ============================== 45 Mark 34 78 Chris...

Can .bat file execute an sql query and return a value?

How can I call a query from a .bat file? (say my query is: select version from system). Can my .bat file save the output that this query returns? I wanna use this output in my NSIS script. ...

MS Access Overflow - Not resolved

I have the following expression in an MS Access Query, where some of these values can be null and despite the cast to a Decimal and the Not Zero (NZ) function, I still get an overflow error. I hope someone can help me find the bug? Sum(Cdec(Nz([TotalPrice]/([tbl_ArticlesPerOrder]![Amount]*[Total])*[tbl_ArtikelRemoveFromSawList]![Amount...

delete duplicates

Is it poosible to delete just one column in a table when display out? company name || name || year|| ____________________________________ walmart || jason || 1990 ___________________________________ walmart || mary || 2000 to company name || name || year|| ____________________________________ walmart || jason || 199...

Crystal report sql expression field

im using asp.net crystal report and this is sql query CONVERT(NUMERIC(8, 2), CASE WHEN CASE WHEN GLDD_DOC_AMOUNT > 0 THEN GLDD_DOC_AMOUNT ELSE 0 END = 0 THEN NULL ELSE CASE WHEN GLDD_DOC_AMOUNT > 0 THEN GLDD_DOC_AMOUNT ELSE 0 END END) Q3_DR, CONVERT(NU...

Oracle subquery does not see the variable from the outer block 2 levels up

I'd like to get in one query a post and the first comment associated with the post. Here is how I do it in PostgreSQL: SELECT p.post_id, (select * from (select comment_body from comments where post_id = p.post_id order by created_date asc) where rownum=1 ) the_first_comment FROM posts p and it works fine. However, in Oracle I'...

Data structure for dynamic dropdowns that cascade

Ok, I'll probably be down-voted on this question but my heads not working and I can't come up with a neat solution. Basically, I need to hold a series of dropdownlists in a database or xml file which will eventually be displayed and used on a page. Problem is I also need them to cascade and hold state after a form submission in MVC. Ha...

Sql Server 2005 Fulltext case sensitivity problem

I seem to have a weird bug in Microsoft SQL Server 2005 where FREETEXT() searches are somewhat case-sensitive despite the collation being case-insensitive (Latin1_General_CI_AS). First of, LIKE queries are perfectly case-insensitive, so WHERE column LIKE '%word%' and WHERE column LIKE '%Word%' return the same results. Also, FREE...

What is the most interesting SQL Question(TSQL Program included) that you encountered?

Actually I am a newbie in SQL SERVER (only 2 months as of now) and want to learn more and master it over the coming days. So I have asked this question. I believe it will help people like me a lot to grow if we follow those that the experienced peoples here have faced or seen so far in their career. Also it will help us in our job or ...

how to import .sql into sqlite3

I have .sql files which has following contents : #cat db.sql create table server(name varchar(50),ipaddress varchar(15),id init) create table client(name varchar(50),ipaddress varchar(15),id init) How to import this file into sqlite ?So that these are created automatically? Thanks. ...

Query design in Access

I have created three queries and I need to consolidate them into a single query. They all have same foreign keys from another table. My objective is to have all the fields (primary key) from the main table displayed in the consolitated query regardless of whether there is record. Please advise ...

SQL Server Rounding Issue Looking for Explanation

Hi Everyone, I've solved this issue but I'm just wondering why this works the way it does. I have a temporary table I am selecting from and am looking to display a a name, the number of records that match this name, and the percentage for that name of the total records. This is the way I originally had it: SELECT name, number, CASE...