We need the sql script to query the table Ditronics.Kiosk.Journal to find journal with mismatch denom information versus amount.
2014-05-23 16:17
405 查看
CREATE TABLE #MoneyTable ( Id INT IDENTITY(1, 1) PRIMARY KEY , MoneyName VARCHAR(50) , Cents INT ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'UnSupported', 0 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarOne', 100 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarTwo', 200 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarFive', 500 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarTen', 1000 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarTwenty', 2000 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarFifty', 5000 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'DollarHundred', 10000 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'CentOne', 1 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'CentFive', 5 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'CentTen', 10 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'CentTwentyFive', 25 ) INSERT INTO #MoneyTable ( MoneyName, Cents ) VALUES ( 'CentFifty', 50 ) SELECT id , Payload.value('(TransactionJournal/TransactionDetail/BillBreakTransactionDetail/BillBreakDetail/MoneyDenom/denom)[1]', 'varchar(50)') AS 'MoneyName' , Payload.value('(TransactionJournal/TransactionDetail/Amount)[1]', 'int') AS 'Cents' , Payload.value('(TransactionJournal/TransactionDualDetail/BillBreakTransactionDetail/BillBreakDetail/MoneyDenom/denom)[1]', 'varchar(50)') AS 'DualMoneyName' , Payload.value('(TransactionJournal/TransactionDualDetail/Amount)[1]', --2.Search the specified node in the specified field 'int') AS 'DualCents' INTO #tempJournal --1.Don't to state create #tempJournal FROM Kiosk.Journal WHERE ModuleTypeId = 3 SELECT * FROM Kiosk.Journal WHERE id NOT IN ( SELECT t1.id FROM #tempJournal t1 , #MoneyTable t2 WHERE ( t1.MoneyName = t2.MoneyName AND t1.Cents = t2.Cents AND t1.DualMoneyName IS NULL AND t1.DualCents IS NULL ) OR ( t1.DualMoneyName = t1.MoneyName AND t1.DualCents = t2.Cents AND t1.MoneyName IS NULL AND t1.Cents IS NULL ) ) AND ModuleTypeId = 3 DROP TABLE #MoneyTable DROP TABLE #tempJournal
相关文章推荐
- sql server query to get the list of column name in a table
- 25.You need to create a table with the following column specifications:
- sql: Query to Display Foreign Key Relationships and Name of the Constraint for Each Table in Database
- MS SQL错误:SQL Server failed with error code 0xc0000000 to spawn a thread to process a new login or connection. Check the SQL Server error log and the Windows event logs for information about possible related problems
- 1Z0-051 25. You need to create a table with the following column specifications:
- two improvement to the "drop all table with T-SQL" solution
- How-to find the SQL that using lots of temp tablespace in Oracle
- Error with hilo in NHibernate - “could not read a hi value - you need to populate the table”
- Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser
- How to find the correct version of JDeveloper to use with eBusiness Suite 11i or Release 12.x
- Cannot connect to WMI provider.You do not have permission or the server is unreachable.Note that you can only manager SQL Server 2005 and later version with SQL Server Configuration Manager.Invalid namespace [0x8004100e]
- Sql Script To set the show sort of data ( up or down )
- Start Oracle Sqlplus with Login Information Script
- error "could not read a hi value - you need to populate the table".
- Query the first 31 to 40 records in the Table A
- Script to Collect DB Upgrade/Migrate Diagnostic Information (dbupgdiag.sql)
- The Essential Guide to Flex 2 with ActionScript 3.0
- SQL Server Setup failed to obtain system account information for the ASPNET
- How do I write a LINQ to Entities query which has the equivalent of the SQL “in” keyword?
- how to deal with fdisk error: Re-reading the partition table failed with error 16: Device or resource busy.